Questions and exercises for Midterm and Final Review

Size: px
Start display at page:

Download "Questions and exercises for Midterm and Final Review"

Transcription

1 Questions and exercises for Midterm and Final Review Scroll down for final Note. Questions/Exercises in green numbers apply to the midterm 1. What steps should one take when solving a problem using a computer? 2. Explain some issues when dealing with the representation of real world objects in a computer program. 3. Explain the notions: model of computation; computational problem; problem instance; algorithm; and program 4. Show the algorithm design algorithm. 5. What might be the resources considered in algorithm analysis? 6. Explain the big-oh class of growth. 7. Explain the big-omega class of growth. 8. Explain the big-theta class of growth. 9. What are the steps in mathematical analysis of nonrecursive algorithms? 10. What are the steps in mathematical analysis of recursive algorithms? 11. From lowest to highest, what is the correct order of the complexities O(n 2 ), O(3n), O(2n), O(n 2 lg n), O(1), O(n lg n), O(n 3 ), O(n!), O(lg n), O(n)? 12. What are the complexities of T 1 (n) = 3n lg n + lg n; T 2 (n) = 2 n + n ; and T 3 (n, k) = k + n, where k less-than or equal to n? From lowest to highest, what is the correct order of the resulting complexities? 13. Suppose we have written a procedure to add m square matrices of size n n. If adding two square matrices requires O (n 2 ) running time, what is the complexity of this procedure in terms of m and n? 14. Suppose we have two algorithms to solve the same problem. One runs in time T 1 (n) = 400n, whereas the other runs in time T 2 (n) = n 2. What are the complexities of these two algorithms? For what values of n might we consider using the algorithm with the higher complexity? 15. How do we account for calls such as memcpy and malloc in analyzing real code? Although these calls often depend on the size of the data processed by an algorithm, they are really more of an implementation detail than part of an algorithm itself. 16. Explain the stack ADT. 17. Explain the list ADT. 18. There are occasions when arrays have advantages over linked lists. When are arrays preferable?

2 19. Explain the queue ADT. 20. Sometimes we need to remove an element from a queue out of sequence (i.e., from somewhere other than the head). What would be the sequence of queue operations to do this if in a queue of five requests, req1,..., req5, we wish to process req1, req3, and req5 immediately while leaving req2 and req4 in the queue in order? What would be the sequence of linked list operations to do this if we morph the queue into a linked list? 21. Recall that each of the linked list data structures presented at the laboratory has a size member. The SLList and DLList data structures also contain a first and last member. Why are each of these members included? 22. When would you use a doubly-linked list instead of a singly-linked one? Why? 23. Show the result of inserting the numbers 32, 11, 22, 15, 17, 2, -3 în a doubly linked list with a sentinel. 24. Show the result of inserting the numbers 32, 11, 22, 15, 17, 2, -3 în a circular queue of capacity Show the result of inserting the numbers 32, 11, 22, 15, 17, 2, -3 în a stack of capacity Determine the value returned by the function (depending on n), and the worst case running time, in big-oh notation, of the following program 27. Determine the value returned by the function (depending on n), and the worst case running time, in big-oh notation, of the following program 28. Define the term "rooted tree" both formally and informally. 29. Define the terms ancestor, descendant, parent, child, sibling as used with rooted trees. 30. Define the terms path, height, depth, level as used with rooted trees. 31. Show the preorder traversal of the tree given in Fig. 1

3 Fig. 1. Example Tree 23. Show the postorder traversal of the tree given in Fig Show the inorder traversal of the tree given in Fig Construct the tree whose preorder traversal is: 1, 2, 5, 3, 6, 10, 7, 11, 12, 4, 8, 9, and inoder traversal is 5, 2, 1, 10, 6, 3, 11, 7, 12, 8, 4, Construct the tree whose postorder traversal is: 5, 2, 10, 6, 11, 12, 7, 3, 8, 9, 4, 1, and inoder traversal is 5, 2, 1, 10, 6, 3, 11, 7, 12, 8, 4, Show the vector contents for an implementation of the tree in Fig Show the contents of the data structures (in a sketch) for an implementation of the tree in Fig. 1 using lists of children. 29. Show the contents of the data structures (in a sketch) for an implementation of the tree in Fig. 1 using leftmost child - right sibling method. 30. Show the binary search tree which results after inserting the nodes with keys 5, 2, 10, 6, 11, 12, 7, 3, 8, 9, 4, 1 in that order, in an empty tree. 31. Show the binary search tree resulted after deleting keys 10, 5 and 6 in that order from the binary search tree of Fig How do we find the smallest node in a binary search tree? What is the runtime complexity to do this in both an unbalanced and balanced binary search tree, in the worst case? How do we find the largest node in a binary search tree? What are the runtime complexities for this? 33. Compare the performance of operations insert (add), delete and find for arrays, doubly-linked lists and BSTs. 34. What is the purpose of static BSTs and what criteria are used to build them? 35. If we would have two functions: bitree_rem_left (for removing the left subtree) and bitree_rem_right (for removing the right subtree), why should we use a postorder traversal used to remove the appropriate subtree? Could a preorder or inorder traversal have been used instead? 36. When might we choose to make use of a tree with a relatively large branching factor, instead of a binary tree, for example? 37. In a binary search tree, the successor of some node x is the next largest node after x. For example, in a binary search tree containing the keys 24,

4 39, 41, 55, 87, 92, the successor of 41 is 55. How do we find the successor of a node in a binary search tree? What is the runtime complexity of this operation? 38. A multiset is a type of set that allows members to occur more than once. How would the runtime complexities of inserting and removing members with a multiset compare with the operations for inserting and removing members from a set? 39. The symmetric difference of two sets consists of those members that are in either of the two sets, but not both. The notation for the symmetric difference of two sets, S1 and S2, is S1? S2. How could we implement a symmetric difference operation using the set operations union, intersection and difference? Could this operation be implemented more efficiently some other way? 40. Sketch the algorithm for HashInsert in a hash table using open addressing. 41. Why are hash tables good for random access but not sequential access? For example, in a database system in which records are to be accessed in a sequential fashion, what is the problem with hashing? 42. What is the worst-case performance of searching for an element in a chained hash table? How do we ensure that this case will not occur? 43. What is the worst-case performance of searching for an element in an open-addressed hash table? How do we ensure that this case will not occur? 44. Explain the generation of hash codes using memory addresses, integer cast and component sum. 45. Explain the generation of hash codes using polynomial accumulation. 46. How can one implement a compression function using the MAD technique? 47. Explain the quadratic hashing rehashing strategy. 48. Explain the double hashing rehashing strategy. 49. Show the hash table which results after inserting the values 5, 2, 10, 6, 11, 12, 7, 3, 8, 9, 4, 1 in a chained hash table with N=5 and hash function h(x)=x mod N. 50. Show the hash table which results after inserting the values 5, 2, 10, 6, 11, 12, 7, 3, 8, 9, 4, 1 in an open addressing hash table with N=16, N'=13 using double hashing, The hash functions are h 1 (x)=x mod N, and h 2 (x)=1+ (x mod N'). 51. What are the operations for the priority queue ADT? 52. Compare the performance of priority queues using sorted and unsorted lists. 53. What is a partially ordered tree?

5 54. Show the result of inserting the value 14 in the POT of Fig Explain the notion "heap". 56. What is an AVL tree? Fig. 2 A partially ordered tree. 57. Draw the AVL tree which result from inserting the keys 52, 04, 09, 35, 43, 17, 22, 11 in an empty tree. 58. Draw the AVL tree resulting after deleting node 09 from the tree of Fig. 3. Fig. 3. An AVL tree. 59. Describe the left-right double rotation in an AVL tree. 60. Draw the AVL tree resulting after deleting node 35 from the tree of Fig. 4. Fig. 4. Another AVL tree. 61. What can you say about the running time for AVL tree operations? 62. What is a 2-3 tree? 63. Show the 2-3 tree which results after inserting the key 13 in the tree of Fig. 5.

6 Fig. 5. A 2-3 tree. 64. Show the 2-3 tree which results after deleting the key 13 in the tree of Fig What is a tree? Fig. 6. Another 2-3 tree. 66. What were the disjoint sets with union and find designed for? 67. Define the operations of the union-find set ADT. 68. Draw a sketch showing a lists implementation for the union-find set ADT with sets: 1: {1, 4, 7}; 2: {2, 3, 6, 9}; 8:{8, 11, 10, 12}. 69. Draw a sketch showing a tree forest implementation for the union-find set ADT with sets: 1: {1, 4, 7}; 2: {2, 3, 6, 9}; 8:{8, 11, 10, 12}. 70. How can one speed up union-find ADT operations? 1. Give an adjacency matrix representation for the graph of Fig. F1. Fig. F1. A graph. 2. Give an adjacency list representation for the graph of Fig F1. 3. How do adjacency list/matrix representations for graphs compare and when should one ore another be used? 4. Apply Dijkstra s algorithm for the graph of Fig. F1 starting at node Apply Prim s algorithm to the graph of Fig F2.

7 6. Apply Kruskal s algorithm to the graph of Fig. F3 Fig F2. Another graph. Fig. F3. Yet another graph. 7. Apply Bellman-Ford algorithm to the graph of Fig. F4. F4. A digraph 8. Apply Floyd s algorithm to the graph of Fig F5. Fig.

8 Fig. F5. Another graph. 9. Use breadth-first search to determine the articulation points of the graph of Fig. F Use depth-first search to determine the articulation points of the graph of Fig. F Determine the transitive closure of the graph of Fig. F Apply topological sort to the dag of Fig. F6. Fig. F6. A Directed Acyclic Graph. 13. Develop a short algorithm for finding cycles in a graph. 14. Consider the following MAXMIN algorithm. How many comparisons does it use? Is it likely to be faster or slower than the divide-and-conquer algorithmin practice? procedure maxmin2(s) comment computes maximum and minimum of S[1..n] in max and min resp. 1. if n is odd then max:=s[n]; min:=s[n] 2. else max:= ; min:= 3. for i := 1 to n/2 do 4. if S[2i 1] S[2i] 5. then small:=s[2i 1]; large:=s[2i] 6. else small:=s[2i]; large:=s[2i 1] 7. if small < min then min:=small 8. if large > max then min:=small 15. A sequence of numbers a 1, a 2, a 3,, a n is oscillating if a i < a i+1 for every odd index i and a i > a i+1 for every even index i. Describe and analyze an efficient algorithm to compute the longest oscillating subsequence in a sequence of n integers. 16. Find the following spanning trees for the weighted graph shown below. (a) A breadth-first spanning tree rooted at s. (b) A depth-first spanning tree rooted at s. (c) A shortest-path tree rooted at s. (d) A minimum spanning tree.

9 You do not need to justify your answers; just clearly indicate the edges of each spanning tree. Yes, one of the edges has negative weight. 17. Describe and analyze an algorithm to compute the size of the largest connected component of black pixels in an n n bitmap B[1..n; 1..n]. For example, given the bitmap below as input, your algorithm should return the number 9, because the largest conected black component (marked with white dots on the right) contains nine pixels. 18. Describe and analyze an algorithm that determines whether a given graph is a tree, where the graph is represented by an adjacency list. 19. Solve the recurrence T(n) = 5T(n/17) + O(n 4/3 ). 20. Solve the recurrence T(n) = 1/n + T(n 1), where T(0) = Suppose you are given an array of n numbers, sorted in increasing order. (a) Describe an O(n)-time algorithm for the following problem: Find two numbers from the list that add up to zero, or report that there is no such pair. In other words, find two numbers a and b such that a + b = 0. (b) Describe an O(n 2 )-time algorithm for the following problem: Find three numbers from the list that add up to zero, or report that there is no such triple. In other words, find three numbers a, b, and c, such that a+b+c = 0. [Hint: Use something similar to part (a) as a subroutine.] 22. Sketch the selection sort algorithm and show how it works on the array containing the keys 82, 31, -13, 45, 99, -1, -7, Sketch the insertion sort algorithm and show how it works on the array containing the keys 82, 31, -13, 45, 99, -1, -7, Sketch the merge sort algorithm and show how it works on the array containing the keys 82, 31, -13, 45, 99, -1, -7, Sketch the quick sort algorithm and show how it works on the array containing the keys 82, 31, -13, 45, 99, -1, -7, Sketch the radix sort algorithm and show how it works on the array containing the keys 82, 31, -13, 45, 99, -1, -7, Sketch the counting sort algorithm and show how it works on the array containing the keys 2, 1, 5, 5, 9, 3, 7, Sketch the bucket sort algorithm and show how it works on the array containing the keys 0.82, 0.31, 0.13, 0.45, 0.99, 0.1, 0.7, What are the criteria used to evaluate the running time of an internal sorting algorithm?

10 30. How do we select a sort algorithm? 31. What strategies ca be in volved for selecting a new E-vertex with branch and bound? 32. Compare the backtracking and branch and bound search strategies. 33. Describe the local search strategy. 34. Apply the local search strategy to the problem of finding the MST of the graph below: 35. Describe the Divide and conquer method for algorithm design 36. Describe the steps in applying dynamic programming strategy when developing an algorithm 37. Suppose we have bit elements that we would like to sort. What would be the efficiency of sorting these using quicksort? What would be the efficiency of sorting these as radix-216 numbers using radix sort? Which approach would be better? Suppose we have bit elements rather than 220 elements. How do quicksort and radix sort compare in this case? 38. In a sorted set, the successor of some node x is the next largest node after x. For example, in a sorted set containing the keys 24, 39, 41, 55, 87, 92, the successor of 41 is 55. How do we find the successor of an element x using binary search? What is the runtime complexity of this operation? 39. Suppose we model an internet using a graph and we determine that the graph contains an articulation point. What are the implications of this? 40. Consider a graph that models a structure of airways, highways in the sky on which airplanes are often required to fly. The structure consists of two types of elements: navigational facilities, called navaids for short, and airways that connect navaids, which are typically within a hundred miles of each other. Airways may be bidirectional or oneway. At certain times some airways are not available for use. Suppose during one of these times we would like to determine whether we can still reach a particular destination. How can we determine this? What is the runtime complexity of solving this problem? 41. Suppose we would like to use a computer to model states in a system. For example, imagine the various states of a traffic-light system at an intersection and the decisions the system has to make. How can we use a graph to model this? 42. The transpose of a directed graph is a graph with the direction of its edges reversed. Formally, for a directed graph G = (V, E ), its transpose is indicated as G T. How could we form the transpose of a graph assuming an adjacency-list representation? What is the runtime complexity of this? 43. The following recursive definition has an error. What is it, and how can we fix it? For a positive integer n, the definition, in its proper form, is common in formally computing the running time of divide-and-conquer algorithms, such as merge sort. Merge sort divides a set of data in half, then divides the halves in half, and continues this way until each division contains a single element. Then, during the unwinding phase, the divisions are merged to produce a final sorted set.

11 44. Analyze the asymptotic time complexity T(n) for the following two divide-and-conquer algorithm. You may assume that n is a power of 2. int foo(a) { n = A.length; if (n==1) { return A[0]; } int half = (int) n/2 int[] A1 = new int[half]; int[] A2 = new int[n-half]; for (int i=0; i <= half-1; i++) { for (int j=0; j <= 1; j++) { if (j==0) A1[i] = A[2i]; else A2[i] = A[2i+1]; } } A2[n-half-1] = A[n-1]; b1 = foo(a1); b2 = foo(a2); if (b1>b2) return b1; else return b2; } 45. Consider a game tree in which there are six marbles, and players 1 and 2 take turns picking from one to three marbles. The player who takes the last marble loses the game. a) Draw the complete tree for this game. b) If the game tree were searched using the alpha-beta pruning technique, and nodes representing configurations with the smallest number of marbles are searched first, which nodes are pruned? c) Who wins the game if both play their best? 46. Give an algorithm that takes an array of n numbers (n is even) and finds the maximum one and the minimum one in 3(n/2)-2 comparisons. 47. Suppose you have n integers in the range from 0 to n 3-1. Explain how to sort them in O(n) time. 48. Develop an algorithm to solve the basic Tower of Hanoi problem, i.e., 3 towers, N disks, and the given rules. 49. How could you make an algorithm for finding the longest path in a graph with only negative weights? 50. Suppose there are three alternatives for dividing a problem of size n into subproblems of smaller size: if you solve 3 subproblems of size n/2, then the cost for combining the solutions of the subproblems to obtain a solution for the original problem is Theta(n 2 sqrt(n)); if you solve 4 subproblems of size n/2, then the cost for combining the solutions is Theta(n 2 ); if you solve 5 subproblems of size n/2, then the cost for combining the solutions is Theta(n log n). Which alternative do you prefer and why? 51. A palindrome is a word w 1 w 2...w k whose reverse w k w k 1...w 1 is the same string, e.g. abbabba. Consider a string A = a 1 a 2... a n. A partitioning of the string is a palindrome partitioning if every substring of the partition is a palindrome. For example, aba b bbabb a b aba is a palindrome partitioning of ababbbabbababa. Design a

12 dynamic programming algorithm to determine the coarsest (i.e. fewest cuts) palindrome partition of A. 52. Consider a directed graph G = (V,E) where each edge is labeled with a character from an alphabet Sigma, and we designate a special vertex s as the start vertex, and another f as the final vertex. We say that G accepts a string A = a 1 a 2... a n if there is a path from s to f of n edges whose labels spell the sequence A. Design an O(( V + E )n) dynamic programming algorithm to determine whether or not A is accepted by G. 53. Give the pseudocode for a greedy algorithm that solves the following optimization problem. Justify briefly why your algorithm finds th optimum solution. What is the asymptotic running time of your algorithm in terms of n? There are n gas stations S 1, S n on E60 highway from Cluj-Napoca to Oradea. On a full tank of gas, your car goes for D miles. Gas station S 1 is in Cluj-Napoca, and each gas station S i for 2 <= i <= n, i sat d i < D kilometers after the previous gas station S i -1, and gas station S n is in Oradea. What is the minimum number of gas stops you must make when driving from Cluj-Napoca to Oradea? 54. Discuss the solution for Travelling salesman problem using branch & bound technique. 55. Apply backtracking technique to solve the following instance of subset sum problem : S={1,3,4,5} and d= The configuration of a playground is given as an n by n grid. Each of the elements in the grid has an elevation, expressed as a positive integer number. Someone places a ball at coordinates (i,j) on this playground. The ball then moves to a lower elevation in neighboring locations. List all the possibilities for the ball to move in order to leave the playground. What is the running time of your algorithm? 57. There is a n <= 26 persons, identified by capital letters, each person having at least n/2 friends. One of these persons owns a book, which the rest of the persons wish to read. Find all ways of passing the book to all the friends of the owner, starting at the owner, and reaching each friends exactly once. Finally, the book should be handed back to the owner. What is the running time of your algorithm? 58. Assume we are given a connected, undirected graph G, with n nodes and m edges. Develop an algorithm to set directions for the edges of the graph such a way that from every vertex there should be an even number of outgoing arcs. What is the running time of your algorithm? 59. Develop and algorithm which constructs shedules for round-robin tournaments (for games like tennis, chess, voleyball, soccer, etc.), where the number of players is not a power of 2. Players (at most 30) are identified by numbers. What algorithm design method did you use? What is the running time of your algorithm? 60. On a chess board, there are m obstacles given by their board coordinates. Also, on that board there is a bishop located at coordinates (i,j) (the upper left corner has coordinates (0,0)). Find the path with the minimum number of moves, which obey the rules of chess game, for the bishop to reach a given position (p,q), avoiding the obstacles. 61. Draw the B+Tree which results after insertion of key 70 in the B+tree below. 62. Draw the B+Tree which results after insertion of key 95 in the B+tree below.

13 63. Draw the B+Tree which results after deletion of key 25 in the B+tree below. 64. What is a multi-way search tree of order m? 65. Use Use the alpha/beta procedure to identify which parts of the tree can be pruned. Clearly identify alpha and beta pruning. 66. An architect has been commissioned to design a new building, called the Data Center. Gary wants his top architectural protégé to design a scale model of the Data Center using precision-cut sticks, but he wants to preclude the model from inadvertently containing any right angles. Gary fabricates a set of n sticks, labeled 1,2,...,n, where stick i has length x i. Before giving the sticks to the protégé, he shows them to you and asks you whether it is possible to create a right triangle using any three of the sticks. Give an efficient algorithm for determining whether there exist three sticks a, b, and c such that the triangle formed from them having sides of lengths x a, x b, and x c is a right triangle (that is, x a 2 + x b 2 = x c 2 ). 67. Argue that any comparison based sorting algorithm can be made to be stable, without affecting the running time by more than a constant factor. 68. Define a linked list with a loop as a linked list in which the tail element points to one of the list s elements and not to NULL. Assume that you are given a linked list L, and two pointers P1, P2 to the head. Write an algorithm that decides whether the list has a loop

14 without modifying the original list. The algorithm should run in time O(n) and additional memory O(1), where n is the number of elements in the list. 69. Use a min-heap to give an O(n log k)-time algorithm which merges k sorted lists into one sorted list, where n is the total number of elements in all the input lists. 70. Let G = (V,E) be an undirected graph, and s be a node in V. Edge (u, v) 2 E is called a circular edge if the distance from s to u is identical to the distance from s to v. Give a linear algorithm that given s finds all circular edges in graph. Explain what data structures you use, and provide complexity analysis. 71. Give (in pseudocode) an O( V + E ) algorithm that takes as input a directed acyclic graph and two vertices s, t, and returns the number of paths from s to t in G. Your algorithm needs only to count the paths, not list them. Hint: Use topological sort as a part of your solution. 72. a) Give an algorithm to either output a message No counterfeit coin, or identify which of three coins: A, B and C is counterfeit. b) Construct a divide and conquer algorithm that divides a set S set of coins into three equal subsets, and uses part (a) to solve small (i.e. 3-coin) sets. 73. Suppose you have analysed a file and determined that the frequency of occurrence of certain characters is as follows: Character a b c d e f Occurences a) Construct the Huffman tree for the characters b) List the codes for each character c) Use the tree to compress the following strings: i) faded ii) abed iii) feed

DESIGN AND ANALYSIS OF ALGORITHMS

DESIGN AND ANALYSIS OF ALGORITHMS DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK Module 1 OBJECTIVE: Algorithms play the central role in both the science and the practice of computing. There are compelling reasons to study algorithms.

More information

CS521 \ Notes for the Final Exam

CS521 \ Notes for the Final Exam CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit Big-O ( ) Small-o ( ) Big- ( ) Small- ( ) Big- ( ) Notes: ( ) ( ) ( ) ( )

More information

Lecture Summary CSC 263H. August 5, 2016

Lecture Summary CSC 263H. August 5, 2016 Lecture Summary CSC 263H August 5, 2016 This document is a very brief overview of what we did in each lecture, it is by no means a replacement for attending lecture or doing the readings. 1. Week 1 2.

More information

Course Review for Finals. Cpt S 223 Fall 2008

Course Review for Finals. Cpt S 223 Fall 2008 Course Review for Finals Cpt S 223 Fall 2008 1 Course Overview Introduction to advanced data structures Algorithmic asymptotic analysis Programming data structures Program design based on performance i.e.,

More information

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I MCA 312: Design and Analysis of Algorithms [Part I : Medium Answer Type Questions] UNIT I 1) What is an Algorithm? What is the need to study Algorithms? 2) Define: a) Time Efficiency b) Space Efficiency

More information

ECE250: Algorithms and Data Structures Final Review Course

ECE250: Algorithms and Data Structures Final Review Course ECE250: Algorithms and Data Structures Final Review Course Ladan Tahvildari, PEng, SMIEEE Professor Software Technologies Applied Research (STAR) Group Dept. of Elect. & Comp. Eng. University of Waterloo

More information

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC) SET - 1 II B. Tech I Semester Supplementary Examinations, May/June - 2016 PART A 1. a) Write a procedure for the Tower of Hanoi problem? b) What you mean by enqueue and dequeue operations in a queue? c)

More information

Table of Contents. Chapter 1: Introduction to Data Structures... 1

Table of Contents. Chapter 1: Introduction to Data Structures... 1 Table of Contents Chapter 1: Introduction to Data Structures... 1 1.1 Data Types in C++... 2 Integer Types... 2 Character Types... 3 Floating-point Types... 3 Variables Names... 4 1.2 Arrays... 4 Extraction

More information

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 Asymptotics, Recurrence and Basic Algorithms 1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 2. O(n) 2. [1 pt] What is the solution to the recurrence T(n) = T(n/2) + n, T(1)

More information

CS301 - Data Structures Glossary By

CS301 - Data Structures Glossary By CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm

More information

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n) CSE 0 Test Your name as it appears on your UTA ID Card Fall 0 Multiple Choice:. Write the letter of your answer on the line ) to the LEFT of each problem.. CIRCLED ANSWERS DO NOT COUNT.. points each. The

More information

) $ f ( n) " %( g( n)

) $ f ( n)  %( g( n) CSE 0 Name Test Spring 008 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to compute the sum of the n elements of an integer array is: # A.

More information

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

& ( D.  mnp ' ( ) n 3. n 2. ( ) C.  n CSE Name Test Summer Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply two n " n matrices is: A. " n C. "% n B. " max( m,n, p). The

More information

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu. 17CA 104DATA STRUCTURES Academic Year : 018-019 Programme : MCA Year / Semester : I / I Question Bank Course Coordinator: Mrs. C.Mallika Course Objectives The student should be able to 1. To understand

More information

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May www.jwjobs.net R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 *******-****** 1. a) Which of the given options provides the

More information

( ) ( ) C. " 1 n. ( ) $ f n. ( ) B. " log( n! ) ( ) and that you already know ( ) ( ) " % g( n) ( ) " #&

( ) ( ) C.  1 n. ( ) $ f n. ( ) B.  log( n! ) ( ) and that you already know ( ) ( )  % g( n) ( )  #& CSE 0 Name Test Summer 008 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time for the following code is in which set? for (i=0; i

More information

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο CSE 220 Name Test Fall 20 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 4 points each. The time to compute the sum of the n elements of an integer array is in:

More information

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment Class: V - CE Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology Sub: Design and Analysis of Algorithms Analysis of Algorithm: Assignment

More information

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D. CSE 0 Name Test Fall 00 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to convert an array, with priorities stored at subscripts through n,

More information

( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1

( ) + n. ( ) = n 1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1 CSE 0 Name Test Summer 00 Last Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose you are sorting millions of keys that consist of three decimal

More information

AP Computer Science 4325

AP Computer Science 4325 4325 Instructional Unit Algorithm Design Techniques -divide-and-conquer The students will be -Decide whether an algorithm -classroom discussion -backtracking able to classify uses divide-and-conquer, -worksheets

More information

CS302 Data Structures using C++

CS302 Data Structures using C++ CS302 Data Structures using C++ Study Guide for the Final Exam Fall 2018 Revision 1.1 This document serves to help you prepare towards the final exam for the Fall 2018 semester. 1. What topics are to be

More information

( D. Θ n. ( ) f n ( ) D. Ο%

( D. Θ n. ( ) f n ( ) D. Ο% CSE 0 Name Test Spring 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to run the code below is in: for i=n; i>=; i--) for j=; j

More information

n 2 ( ) ( ) + n is in Θ n logn

n 2 ( ) ( ) + n is in Θ n logn CSE Test Spring Name Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply an m n matrix and a n p matrix is in: A. Θ( n) B. Θ( max(

More information

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

( ). Which of ( ) ( )  #& ( )  # g( n) ( )  # f ( n) Test 1 CSE 0 Name Test Summer 006 Last Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply two n x n matrices is: A. "( n) B. "( nlogn) # C.

More information

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο CSE 0 Name Test Fall 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally

More information

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305 Q.1 If h is any hashing function and is used to hash n keys in to a table of size m, where n

More information

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

End-Term Examination Second Semester [MCA] MAY-JUNE 2006 (Please write your Roll No. immediately) Roll No. Paper Code: MCA-102 End-Term Examination Second Semester [MCA] MAY-JUNE 2006 Subject: Data Structure Time: 3 Hours Maximum Marks: 60 Note: Question 1.

More information

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer) COSC 2007 Data Structures II Final Exam Thursday, April 13 th, 2006 This is a closed book and closed notes exam. There are total 3 parts. Please answer the questions in the provided space and use back

More information

CSci 231 Final Review

CSci 231 Final Review CSci 231 Final Review Here is a list of topics for the final. Generally you are responsible for anything discussed in class (except topics that appear italicized), and anything appearing on the homeworks.

More information

Garbage Collection: recycling unused memory

Garbage Collection: recycling unused memory Outline backtracking garbage collection trees binary search trees tree traversal binary search tree algorithms: add, remove, traverse binary node class 1 Backtracking finding a path through a maze is an

More information

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each CSE 0-00 Test Spring 0 Name Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose f ( x) is a monotonically increasing function. Which of the

More information

END-TERM EXAMINATION

END-TERM EXAMINATION (Please Write your Exam Roll No. immediately) Exam. Roll No... END-TERM EXAMINATION Paper Code : MCA-205 DECEMBER 2006 Subject: Design and analysis of algorithm Time: 3 Hours Maximum Marks: 60 Note: Attempt

More information

( ) 1 B. 1. Suppose f x

( ) 1 B. 1. Suppose f x CSE Name Test Spring Last Digits of Student ID Multiple Choice. Write your answer to the LEFT of each problem. points each is a monotonically increasing function. Which of the following approximates the

More information

Your favorite blog : (popularly known as VIJAY JOTANI S BLOG..now in facebook.join ON FB VIJAY

Your favorite blog :  (popularly known as VIJAY JOTANI S BLOG..now in facebook.join ON FB VIJAY Course Code : BCS-042 Course Title : Introduction to Algorithm Design Assignment Number : BCA(IV)-042/Assign/14-15 Maximum Marks : 80 Weightage : 25% Last Date of Submission : 15th October, 2014 (For July

More information

( ) n 3. n 2 ( ) D. Ο

( ) n 3. n 2 ( ) D. Ο CSE 0 Name Test Summer 0 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply two n n matrices is: A. Θ( n) B. Θ( max( m,n, p) ) C.

More information

Course Review. Cpt S 223 Fall 2009

Course Review. Cpt S 223 Fall 2009 Course Review Cpt S 223 Fall 2009 1 Final Exam When: Tuesday (12/15) 8-10am Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes Homeworks & program

More information

Data Structures Brett Bernstein

Data Structures Brett Bernstein Data Structures Brett Bernstein Final Review 1. Consider a binary tree of height k. (a) What is the maximum number of nodes? (b) What is the maximum number of leaves? (c) What is the minimum number of

More information

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.) CSE 0 Name Test Spring 006 Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose f ( x) is a monotonically increasing function. Which of the

More information

Data Structures Question Bank Multiple Choice

Data Structures Question Bank Multiple Choice Section 1. Fundamentals: Complexity, Algorthm Analysis 1. An algorithm solves A single problem or function Multiple problems or functions Has a single programming language implementation 2. A solution

More information

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE A6-R3: DATA STRUCTURE THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered in the TEAR-OFF

More information

n 2 C. Θ n ( ) Ο f ( n) B. n 2 Ω( n logn)

n 2 C. Θ n ( ) Ο f ( n) B. n 2 Ω( n logn) CSE 0 Name Test Fall 0 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to find the maximum of the n elements of an integer array is in: A.

More information

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name Course Code Class Branch DATA STRUCTURES ACS002 B. Tech

More information

CS8391-DATA STRUCTURES QUESTION BANK UNIT I

CS8391-DATA STRUCTURES QUESTION BANK UNIT I CS8391-DATA STRUCTURES QUESTION BANK UNIT I 2MARKS 1.Define data structure. The data structure can be defined as the collection of elements and all the possible operations which are required for those

More information

Introduction to Algorithms Third Edition

Introduction to Algorithms Third Edition Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein Introduction to Algorithms Third Edition The MIT Press Cambridge, Massachusetts London, England Preface xiü I Foundations Introduction

More information

Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017

Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017 Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017 Name: The entire practice examination is 1005 points. 1. True or False. [5 points each] The time to heapsort an array of

More information

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 Asymptotics, Recurrence and Basic Algorithms 1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 1. O(logn) 2. O(n) 3. O(nlogn) 4. O(n 2 ) 5. O(2 n ) 2. [1 pt] What is the solution

More information

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Introduction to Algorithms Preface xiii 1 Introduction 1 1.1 Algorithms 1 1.2 Analyzing algorithms 6 1.3 Designing algorithms 1 1 1.4 Summary 1 6

More information

COMP 251 Winter 2017 Online quizzes with answers

COMP 251 Winter 2017 Online quizzes with answers COMP 251 Winter 2017 Online quizzes with answers Open Addressing (2) Which of the following assertions are true about open address tables? A. You cannot store more records than the total number of slots

More information

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE A6-R3: DATA STRUCTURE THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered in the TEAR-OFF

More information

Cpt S 223 Fall Cpt S 223. School of EECS, WSU

Cpt S 223 Fall Cpt S 223. School of EECS, WSU Course Review Cpt S 223 Fall 2012 1 Final Exam When: Monday (December 10) 8 10 AM Where: in class (Sloan 150) Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes

More information

MLR Institute of Technology

MLR Institute of Technology MLR Institute of Technology Laxma Reddy Avenue, Dundigal, Quthbullapur (M), Hyderabad 500 043 Phone Nos: 08418 204066 / 204088, Fax : 08418 204088 TUTORIAL QUESTION BANK Course Name : DATA STRUCTURES Course

More information

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8) B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER 2009 EC 2202 DATA STRUCTURES AND OBJECT ORIENTED Time: Three hours PROGRAMMING IN C++ Answer ALL questions Maximum: 100 Marks 1. When do we declare a

More information

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1 CSE 0 Name Test Fall 00 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each t. What is the value of k? k=0 A. k B. t C. t+ D. t+ +. Suppose that you have

More information

Course Review. Cpt S 223 Fall 2010

Course Review. Cpt S 223 Fall 2010 Course Review Cpt S 223 Fall 2010 1 Final Exam When: Thursday (12/16) 8-10am Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes Homeworks & program

More information

Design and Analysis of Algorithms - - Assessment

Design and Analysis of Algorithms - - Assessment X Courses» Design and Analysis of Algorithms Week 1 Quiz 1) In the code fragment below, start and end are integer values and prime(x) is a function that returns true if x is a prime number and false otherwise.

More information

DATA STRUCTURES AND ALGORITHMS

DATA STRUCTURES AND ALGORITHMS DATA STRUCTURES AND ALGORITHMS UNIT 1 - LINEAR DATASTRUCTURES 1. Write down the definition of data structures? A data structure is a mathematical or logical way of organizing data in the memory that consider

More information

Review of course COMP-251B winter 2010

Review of course COMP-251B winter 2010 Review of course COMP-251B winter 2010 Lecture 1. Book Section 15.2 : Chained matrix product Matrix product is associative Computing all possible ways of parenthesizing Recursive solution Worst-case running-time

More information

Algorithm Design (8) Graph Algorithms 1/2

Algorithm Design (8) Graph Algorithms 1/2 Graph Algorithm Design (8) Graph Algorithms / Graph:, : A finite set of vertices (or nodes) : A finite set of edges (or arcs or branches) each of which connect two vertices Takashi Chikayama School of

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 3 Definitions an undirected graph G = (V, E)

More information

Direct Addressing Hash table: Collision resolution how handle collisions Hash Functions:

Direct Addressing Hash table: Collision resolution how handle collisions Hash Functions: Direct Addressing - key is index into array => O(1) lookup Hash table: -hash function maps key to index in table -if universe of keys > # table entries then hash functions collision are guaranteed => need

More information

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions Introduction Chapter 9 Graph Algorithms graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 2 Definitions an undirected graph G = (V, E) is

More information

Department of Computer Science and Technology

Department of Computer Science and Technology UNIT : Stack & Queue Short Questions 1 1 1 1 1 1 1 1 20) 2 What is the difference between Data and Information? Define Data, Information, and Data Structure. List the primitive data structure. List the

More information

UCS-406 (Data Structure) Lab Assignment-1 (2 weeks)

UCS-406 (Data Structure) Lab Assignment-1 (2 weeks) UCS-40 (Data Structure) Lab Assignment- (2 weeks) Implement the following programs in C/C++/Python/Java using functions a) Insertion Sort b) Bubble Sort c) Selection Sort d) Linear Search e) Binary Search

More information

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302 Topics VCU, Department of Computer Science CMSC 302 Trees Vojislav Kecman Terminology Trees as Models Some Tree Theorems Applications of Trees Binary Search Tree Decision Tree Tree Traversal Spanning Trees

More information

L.J. Institute of Engineering & Technology Semester: VIII (2016)

L.J. Institute of Engineering & Technology Semester: VIII (2016) Subject Name: Design & Analysis of Algorithm Subject Code:1810 Faculties: Mitesh Thakkar Sr. UNIT-1 Basics of Algorithms and Mathematics No 1 What is an algorithm? What do you mean by correct algorithm?

More information

Lecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions

Lecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions U.C. Berkeley CS70 : Algorithms Midterm 2 Solutions Lecturers: Sanjam Garg and Prasad aghavra March 20, 207 Midterm 2 Solutions. (0 points) True/False Clearly put your answers in the answer box in front

More information

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned.

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned. Course Name: B.Tech. 3 th Sem. Subject: Data Structures No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours Paper Code: ETCS-209 Topic Details No of Hours Planned

More information

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the elements may locate at far positions

More information

Algorithm Design Techniques. Hwansoo Han

Algorithm Design Techniques. Hwansoo Han Algorithm Design Techniques Hwansoo Han Algorithm Design General techniques to yield effective algorithms Divide-and-Conquer Dynamic programming Greedy techniques Backtracking Local search 2 Divide-and-Conquer

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures 3 Definitions an undirected graph G = (V, E) is a

More information

CSE 373 Final Exam 3/14/06 Sample Solution

CSE 373 Final Exam 3/14/06 Sample Solution Question 1. (6 points) A priority queue is a data structure that supports storing a set of values, each of which has an associated key. Each key-value pair is an entry in the priority queue. The basic

More information

ASSIGNMENTS. Progra m Outcom e. Chapter Q. No. Outcom e (CO) I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n))

ASSIGNMENTS. Progra m Outcom e. Chapter Q. No. Outcom e (CO) I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n)) ASSIGNMENTS Chapter Q. No. Questions Course Outcom e (CO) Progra m Outcom e I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n)) 2 3. What is the time complexity of the algorithm? 4

More information

21# 33# 90# 91# 34# # 39# # # 31# 98# 0# 1# 2# 3# 4# 5# 6# 7# 8# 9# 10# #

21# 33# 90# 91# 34# # 39# # # 31# 98# 0# 1# 2# 3# 4# 5# 6# 7# 8# 9# 10# # 1. Prove that n log n n is Ω(n). York University EECS 11Z Winter 1 Problem Set 3 Instructor: James Elder Solutions log n n. Thus n log n n n n n log n n Ω(n).. Show that n is Ω (n log n). We seek a c >,

More information

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION COURSE TITLE DATA STRUCTURE DETAILED SYLLABUS SR.NO NAME OF CHAPTERS & DETAILS HOURS ALLOTTED 1 USER DEFINED DATATYPE /STRUCTURE About structure Defining structure Accessing structure element Array of

More information

Final Examination CSE 100 UCSD (Practice)

Final Examination CSE 100 UCSD (Practice) Final Examination UCSD (Practice) RULES: 1. Don t start the exam until the instructor says to. 2. This is a closed-book, closed-notes, no-calculator exam. Don t refer to any materials other than the exam

More information

12 Abstract Data Types

12 Abstract Data Types 12 Abstract Data Types 12.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT). Define

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures Chapter 9 Graph s 2 Definitions Definitions an undirected graph is a finite set

More information

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 The data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve this problem we should Use better data structures

More information

Solutions to Exam Data structures (X and NV)

Solutions to Exam Data structures (X and NV) Solutions to Exam Data structures X and NV 2005102. 1. a Insert the keys 9, 6, 2,, 97, 1 into a binary search tree BST. Draw the final tree. See Figure 1. b Add NIL nodes to the tree of 1a and color it

More information

1 5,9,2,7,6,10,4,3,8,1 The first number (5) is automatically the first number of the sorted list

1 5,9,2,7,6,10,4,3,8,1 The first number (5) is automatically the first number of the sorted list Algorithms One of the more challenging aspects of Computer Science are algorithms. An algorithm is a plan that solves a problem. When assembling a bicycle based on the included instructions, in this case,

More information

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance Course goals exposure to another language C++ Object-oriented principles knowledge of specific data structures lists, stacks & queues, priority queues, dynamic dictionaries, graphs impact of DS design

More information

Data Structures and Algorithm Analysis in C++

Data Structures and Algorithm Analysis in C++ INTERNATIONAL EDITION Data Structures and Algorithm Analysis in C++ FOURTH EDITION Mark A. Weiss Data Structures and Algorithm Analysis in C++, International Edition Table of Contents Cover Title Contents

More information

Second Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

Second Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms... Second Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms.... Q1) Let the keys are 28, 47, 20, 36, 43, 23, 25, 54 and table size is 11 then H(28)=28%11=6; H(47)=47%11=3;

More information

4.1.2 Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting...

4.1.2 Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting... Contents 1 Introduction... 1 1.1 What is Competitive Programming?... 1 1.1.1 Programming Contests.... 2 1.1.2 Tips for Practicing.... 3 1.2 About This Book... 3 1.3 CSES Problem Set... 5 1.4 Other Resources...

More information

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Introduction and Overview

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Introduction and Overview Computer Science 385 Analysis of Algorithms Siena College Spring 2011 Topic Notes: Introduction and Overview Welcome to Analysis of Algorithms! What is an Algorithm? A possible definition: a step-by-step

More information

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers? Review for Final (Chapter 6 13, 15) 6. Template functions & classes 1) What is the primary purpose of template functions? A. To allow a single function to be used with varying types of arguments B. To

More information

Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass Marks: 24

Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass Marks: 24 Prepared By ASCOL CSIT 2070 Batch Institute of Science and Technology 2065 Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass

More information

Computer Science E-22 Practice Final Exam

Computer Science E-22 Practice Final Exam name Computer Science E-22 This exam consists of three parts. Part I has 10 multiple-choice questions that you must complete. Part II consists of 4 multi-part problems, of which you must complete 3, and

More information

CS8391-DATA STRUCTURES

CS8391-DATA STRUCTURES ST.JOSEPH COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERI NG CS8391-DATA STRUCTURES QUESTION BANK UNIT I 2MARKS 1.Explain the term data structure. The data structure can be defined

More information

Graph Algorithms (part 3 of CSC 282),

Graph Algorithms (part 3 of CSC 282), Graph Algorithms (part of CSC 8), http://www.cs.rochester.edu/~stefanko/teaching/11cs8 Homework problem sessions are in CSB 601, 6:1-7:1pm on Oct. (Wednesday), Oct. 1 (Wednesday), and on Oct. 19 (Wednesday);

More information

CSE373: Data Structures & Algorithms Lecture 28: Final review and class wrap-up. Nicki Dell Spring 2014

CSE373: Data Structures & Algorithms Lecture 28: Final review and class wrap-up. Nicki Dell Spring 2014 CSE373: Data Structures & Algorithms Lecture 28: Final review and class wrap-up Nicki Dell Spring 2014 Final Exam As also indicated on the web page: Next Tuesday, 2:30-4:20 in this room Cumulative but

More information

a) For the binary tree shown below, what are the preorder, inorder and post order traversals.

a) For the binary tree shown below, what are the preorder, inorder and post order traversals. CS61CS61B Fall 2014 Guerrilla Section 2 Solutions 1. Trees a) For the binary tree shown below, what are the preorder, inorder and post order traversals. 23 / \ 47 0 / / \ 9 15 100 / \ / \ \ 1 935 12 42

More information

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 043 INFORMATION TECHNOLOGY TUTORIAL QUESTION BANK Course Name : DESIGN AND ANALYSIS OF ALGORITHMS Course Code : AIT001 Class

More information

CS 8391 DATA STRUCTURES

CS 8391 DATA STRUCTURES DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK CS 8391 DATA STRUCTURES UNIT- I PART A 1. Define: data structure. A data structure is a way of storing and organizing data in the memory for

More information

Graph Algorithms (part 3 of CSC 282),

Graph Algorithms (part 3 of CSC 282), Graph Algorithms (part of CSC 8), http://www.cs.rochester.edu/~stefanko/teaching/10cs8 1 Schedule Homework is due Thursday, Oct 1. The QUIZ will be on Tuesday, Oct. 6. List of algorithms covered in the

More information

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May Code No: R21051 R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 DATA STRUCTURES (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 Answer any FIVE Questions All Questions carry

More information

(a) Write code to do this without using any floating-point arithmetic. Efficiency is not a concern here.

(a) Write code to do this without using any floating-point arithmetic. Efficiency is not a concern here. CS 146 Final Exam 1 Solutions by Dr. Beeson 1. Analysis of non-recursive algorithms. Consider the problem of counting the number of points with integer coordinates (x,y) on the circle of radius R, where

More information