Data Structures -2 nd exam- 授課教師 : 李錫智 教授 1. 1.[10] Please answer the following questions about stack: What is the response of the statement “(new stack()).isEmpty()”?

Slides:



Advertisements
Similar presentations
Introduction to computers Exam 2 授課教授:李錫智. Question_1 For the following program: Suppose the user enters 43 、 57 in the text boxes numberBox1 and numberBox2,
Advertisements

布林代數的應用--- 全及項(最小項)和全或項(最大項)展開式
: A-Sequence 星級 : ★★☆☆☆ 題組: Online-judge.uva.es PROBLEM SET Volume CIX 題號: Problem D : A-Sequence 解題者:薛祖淵 解題日期: 2006 年 2 月 21 日 題意:一開始先輸入一個.
:Word Morphing ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10508:word morphing 解題者:楊家豪 解題日期: 2006 年 5 月 21 日 題意: 第一行給你兩個正整數, 第一個代表下面會出現幾個字串,
1 Q10276: Hanoi Tower Troubles Again! 星級 : ★★★ 題組: Online-judge.uva.es PROBLEM SET Volume CII 題號: Q10276: Hanoi Tower Troubles Again! 解題者:薛祖淵 解題日期: 2006.
Instructor: Ching-Chi Lin 林清池 助理教授
3Com Switch 4500 切VLAN教學.
授課教授:李錫智 Data Structures -1 st exam-. 1.[10] We define f(n) = O(g(n)) if and only if there is a real constant c>0 and an integer constant n 0 >0, such.
期末專題 - 吊人頭遊戲 第 35 組 組員 : 電機系 49841XXXX XXX 電機系 49841OOOO OOO.
授課教授:李錫智 Data Structures -2 nd exam-. 1.[15] A simple way for implementing the vector ADT is to use an array A, where A[i] stores the element at rank.
授課教授:李錫智 Data Structures -3 rd exam-. 1.[5] Refer to the two trees in Fig. 1. Let’s define the balance factor BF of a node to be the absolute value of.
Introduction to Computers - 2 nd exam- 授課教授:李錫智. 1. Double the Number
Regular Expression Since Java Regular Expression 在字串的使用上, 有一種用途是接收使用者鍵入 的資料 – 身份證字號、電話號碼、或者是電子郵件帳號等等 為了確保後續的處理正確, 通常都會希望使用者 依據特定的格式輸入, 以避免使用者輸入不合乎.
1 Web of Science 利用指引 單元二 瀏覽與處理查詢結果. 2 瀏覽檢索結果 查出的結果,預設以時間排列, 使用者可改變結果的排列方式: 還可以依被引用次數、相關度、 第一作者、刊名、出版年等排序 回到前先查的結果畫面 點選想看資料的完整書目 本館訂購範圍的期刊 全文,便可直接連結.
Review of Chapter 3 - 已學過的 rules( 回顧 )- 朝陽科技大學 資訊管理系 李麗華 教授.
:New Land ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11871: New Land 解題者:施博修 解題日期: 2011 年 6 月 8 日 題意:國王有一個懶兒子,為了勞動兒子,他想了一個 辦法,令他在某天早上開始走路,直到太陽下山前,靠.
: The Playboy Chimp ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10611: The Playboy Chimp 解題者:蔡昇宇 解題日期: 2010 年 2 月 28 日 題意:給一已排序的數列 S( 升冪.
Monte Carlo Simulation Part.2 Metropolis Algorithm Dept. Phys. Tunghai Univ. Numerical Methods C. T. Shih.
Hint of Homework 4 jinnjy. Outline Hint of exercise 3.18.
Introduction to Java Programming Lecture 17 Abstract Classes & Interfaces.
24-6 設定開始與結束場景中的 程式 最後我們要替這個遊戲收個尾, 幫它把開始 的等待畫面跟結束畫面處理一下。
Hint of final exams jinnjy. Outline Hint of final 2006 (6/28/2007)
計算機概論 - 排序 1 排序 (Sorting) 李明山 編撰 ※手動換頁.
: Happy Number ★ ? 題組: Problem Set Archive with Online Judge 題號: 10591: Happy Number 解題者:陳瀅文 解題日期: 2006 年 6 月 6 日 題意:判斷一個正整數 N 是否為 Happy Number.
: Fast and Easy Data Compressor ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10043: Fast and Easy Data Compressor 解題者:葉貫中 解題日期: 2007 年 3.
Chapter 2 Getting Started Insertion Sort: 能有效率地排序小數字的演算法 範例 :
: Count DePrimes ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11408: Count DePrimes 解題者:李育賢 解題日期: 2008 年 9 月 2 日 題意: 題目會給你二個數字 a,b( 2 ≦ a ≦ 5,000,000,a.
短缺,盈餘與均衡. 遊戲規則  老師想出售一些學生喜歡的小食。  老師首先講出價錢,有興趣買的請舉手。
: Multisets and Sequences ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11023: Multisets and Sequences 解題者:葉貫中 解題日期: 2007 年 4 月 24 日 題意:在這個題目中,我們要定義.
:Nuts for nuts..Nuts for nuts.. ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 10944:Nuts for nuts.. 解題者:楊家豪 解題日期: 2006 年 2 月 題意: 給定兩個正整數 x,y.
6 -1 Chapter 6 Sorting Sorting A file of size n is a sequence of n items. Each item in the file is called a record. KeyOther fields Record 14DDD.
資料結構實習-一 參數傳遞.
6-2 認識元件庫與內建元件庫 Flash 的元件庫分兩種, 一種是每個動畫專 屬的元件庫 (Library) ;另一種則是內建元 件庫 (Common Libraries), 兩者皆可透過 『視窗』功能表來開啟, 以下即為您說明。
Lecture 7 Sorting in Linear Time. Sorting in Linear Time2 7.1 Lower bounds for sorting 本節探討排序所耗用的時間複雜度下限。 任何一個以比較為基礎排序的演算法,排序 n 個元 素時至少耗用 Ω(nlogn) 次比較。
: Lucky Number ★★★★☆ 題組: Proble Set Archive with Online Judge 題號: 10909: Lucky Number 解題者:李育賢 解題日期: 2008 年 4 月 25 日 題意:給一個奇數數列 1,3,5,7,9,11,13,15…
JAVA 程式設計與資料結構 第二十章 Searching. Sequential Searching Sequential Searching 是最簡單的一種搜尋法,此演 算法可應用在 Array 或是 Linked List 此等資料結構。 Sequential Searching 的 worst-case.
資料結構實習-二.
演算法 8-1 最大數及最小數找法 8-2 排序 8-3 二元搜尋法.
: Automatic correction of misspellings ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11048: Automatic correction of misspellings 解題者:陳宜佐 解題日期:
Review of Chapter 9 張啟中. Inheritance Hierarchy Min PQ Max PQ Min Heap Mergeable Min PQ DeapMin-Max Min-LeftistMin-SkewMinFHeap MinBHeap DEPQMax Heap Symmetric.
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
Learning Method in Multilingual Speech Recognition Author : Hui Lin, Li Deng, Jasha Droppo Professor: 陳嘉平 Reporter: 許峰閤.
Chapter 10 m-way 搜尋樹與B-Tree
演算法課程 (Algorithms) 國立聯合大學 資訊管理學系 陳士杰老師 Course 7 貪婪法則 Greedy Approach.
幼兒行為觀察與記錄 第五章 觀察記錄法的簡介.
實驗四 4X4矩陣鍵盤實驗 4X4矩陣鍵盤輸入並輸出至七段式顯示器.
1/17 A Study on Separation between Acoustic Models and Its Application Author : Yu Tsao, Jinyu Li, Chin-Hui Lee Professor : 陳嘉平 Reporter : 許峰閤.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2009.
中序轉後序 藉由由左向右掃瞄中序運算式產生後序運算式,遇到 運算元就直接輸出,遇到運算符號則先存入堆疊,將 優先權較高者輸出。 範例: a + b * c TokenStack [0] [1] [2] topoutput aa ++0a b+0ab *+ *1ab c+ *1abc eosabc*+
: Problem E Antimatter Ray Clearcutting ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11008: Problem E Antimatter Ray Clearcutting 解題者:林王智瑞.
Teacher : Ing-Jer Huang TA : Chien-Hung Chen 2015/6/30 Course Embedded Systems : Principles and Implementations Weekly Preview Question CH7.1~CH /12/26.
幼兒行為觀察與記錄 第十章 軼事記錄法.
-Artificial Neural Network- Matlab操作介紹 -以類神經網路BPN Model為例
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2010.
: SAM I AM ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11419: SAM I AM 解題者:李重儀 解題日期: 2008 年 9 月 11 日 題意: 簡單的說,就是一個長方形的廟裡面有敵人,然 後可以橫的方向開砲或縱向開砲,每次開砲可以.
: Finding Paths in Grid ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11486: Finding Paths in Grid 解題者:李重儀 解題日期: 2008 年 10 月 14 日 題意:給一個 7 個 column.
:Problem E.Stone Game ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10165: Problem E.Stone Game 解題者:李濟宇 解題日期: 2006 年 3 月 26 日 題意: Jack 與 Jim.
幼兒行為觀察與記錄 第八章 事件取樣法.
: How many 0's? ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11038: How many 0’s? 解題者:楊鵬宇 解題日期: 2007 年 5 月 15 日 題意:寫下題目給的 m 與 n(m
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
Failure Candidate Identification for Silicon Debug 指導教授 : 曾王道 學生 : 卜竹君 許正明.
Data Structures -3 rd test- 2015/06/01 授課教授:李錫智. Question 1 Suppose we use an array to implement a sorted list. Please answer the following questions.
Data Structures -Final exam- 2015/6/22 授課教授:李錫智. Question 1. Let a hash table have 13 entries. Suppose we have 10 integer keys: 68, 100, 58, 80, 72, 101,
Data Structures -3 st exam- 授課教師 : 李錫智 教授. 1. [5] Assume we have a binary tree which is implemented in a pointer-based scheme. Describe how to know the.
Java Just-In-Time Compiler in hand-held system 指導教授 單智君老師 指導教授 單智君老師 李政仲 張淳恩 王信安.
Data Structures -3 rd exam- 授課教授:李錫智. 1.[10] Suppose we want to implement a queue by using the following List operations: getLength(); remove(position);
Data Structures -1 st exam- 授課教師 : 李錫智 教授. 1.[10] Suppose we have the ADT Bag which has the following operations: bool isEmpty(): tests whether Bag is.
Data Structures -3 rd exam- 授課教師 : 李錫智 教授. 1.[10] Please answer the following questions about queue: [ 2] What is the response of the statement: “(new.
Group 2 Block 胡貴蓉 Project 2 JMVC code tracing.
Presentation transcript:

Data Structures -2 nd exam- 授課教師 : 李錫智 教授 1

1.[10] Please answer the following questions about stack: What is the response of the statement “(new stack()).isEmpty()”? What is the response of the statement “((new stack()).push(item)).peek()”? What is the response of the following statement: “(((new stack()).push(item)).peek()).pop()”? What is the response of the following statement: “((((new stack()).push(item)).peek()).pop()).push(item)”? What is the response of the following statement: “((((new stack()).push(item)).peek()).pop()).pop()”? 2

Ans: true item true false 3

2.[10] Suppose we have a language L = { s$s' : s is a possibly empty string of characters other than $, s' = reverse(s)}. Please describe how to use a stack to determine whether the following string belongs to L: “abcd$dcba” “tak$tak” “pk$kpw” “hike$ek” “$xy” 4

Ans: 將字串裡的字元一一放進 stack ,如果放進的是 $ 則開始 peek ,第一次 peek 的字元與剩下還沒放進 stack 的第一個字元比較,如果相同,則開始 pop , 接著第二次 peek ,如果 peek 的字元與剩下的第二 個字元一樣,則 pop ,依此類推,如果 peek 的字 元與相對比較的字元不一樣,或者剩下的字元已 經比完但是 stack 裡還沒空,或者 stack 空了,但是 剩下的字元還沒比完,上述 3 個情況都不屬於 language L 。 5

3.[10] Suppose we have a stack, called aStack, implemented by array, as shown below (the left end is the bottom of the stack and index 0): p, q, r and top = 2. Note that the capacity of the array is 10. After executing the following statement: “(((aStack.pop()).push(x)).push(w)).peek()” Draw the resulting stack [3]. What is the returned value [2]? After executing the following statement: “(((((aStack.peek()).push(w)).push(a)).pop()).pop()).peek()” Draw the resulting stack [3]. What is the returned value [2]? 6

Ans: 7

4.[10] Please answer the following questions about list: What is the response of the statement “(new List()).getLength()”? What is the response of the statement “(new List()).remove(1)”? What is the response of the following statement: “((((new List()).insert(1,a)).insert(1,b)).remove(2)).isEmpty()”? What is the response of the following statement: “((((new List()).insert(1,a)).insert(1,b)).insert(2,c)).getEntry(3)”? What is the response of the following statement: “(((((new List()).insert(1,a)).insert(1,b)).setEntry(2,k)).insert(2,c)).getEntr y(3)”? 8

Ans: 0 false a k 9

5.[10] Suppose we have a list, called aList, implemented by array, as shown below (the left end is position 1 and index 0): w, x, y Note that the capacity of the array is 10. After executing the following statement: “(((aList.insert(1,a)).insert(1,b)).insert(2,c)).getEntry(3)” Draw the resulting list [3]. What is the returned value [2]? After executing the following statement: “((((aList.insert(1,a)).insert(1,b)).setEntry(2,k)).insert(2,c)).getEntry (3)” Draw the resulting list [3]. What is the returned value [2]? 10

Ans: 11

6.[10] Given an array: 37, 13, 29, 14, 10 Please sort it in ascending order using Selection Sort. Draw the array after each swap. 12

Ans: 13

7.[10] Given an array: 37, 13, 29, 14, 10 Please sort it in ascending order using Bubble Sort. Draw the array after each pass. 14

Ans: 15

16

17

8.[10] Given an array: 37, 13, 29, 14, 10 Please sort it in ascending order using Insertion Sort. Draw the array after each insertion. 18

Ans: 19

9.[10] Given an array: 2, 6, -2, 5, 4, 0, -5, 7, 1, 8, 3 and indexFromLeft = 0 and indexFromRight = 9. Please partition it using the rightmost element as the pivot. Show the array, indexFromLeft, and indexFromRight after each swap. 20

Ans: 21

10.[10] What are the best case and the worst case in efficiency, expressed in big O, of the sorting methods Selection Sort [2], Bubble Sort [2], Insertion Sort [2], Quick Sort [2], and Merge Sort [2]. Ans: 22