COMP 1020 Study Guide - Midterm Guide: Time Complexity, Insertion Sort, Biasing

166 views14 pages
lavenderbeaver188 and 10 others unlocked
COMP 1020 Full Course Notes
12
COMP 1020 Full Course Notes
Verified Note
12 documents

Document Summary

Cs1020 - data structures and algorithms i - april 2013. Section a (8 multiple choice questions: 24 marks) Stack s = new stack(); s. push(new integer(5)); s. push(new integer(6)); s. push(s. peek()); s. push(new integer(7)); q. enqueue(s. pop()); q. enqueue(new integer(5)); q. enqueue(new integer(6)); Infix expressions do not require precedence rules: parentheses are needed in all arithmetic expressions. B: postfix and prefix expressions do not require precedence rules, fully parenthesized expressions are difficult to recognize and evaluate, none of the above, consider the implementation of the queue using an array. The offer (enqueue) method would require linear time. The isempty method would require linear time: the constructor would require linear time. C: the poll (dequeue) method would require linear time. The peek method would require linear time: an efficient algorithm to determine if an array a with n elements contains duplicate. A: merge sort, quick sort, radix sort, none of the above, mr. qian decides to use a circular linked list to represent fifo queue.