





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Briefly explain the approaches to developing algorithms? - ANSGreedy Approach - finding solution by choosing next best option. Divide and Conquer - dividing the problem to a minimum possible sub- problem and solving them independently. Dynamic Programming - dividing the problem into a minimum number of possible problems and solving them in a combined manner. How are selection sort and insertion sort different? - ANSBoth are sorting techniques that maintain two sub-list: sorted and unsorted. Both take one element at a time and places it into the sorted sub-list. Insertion sort works on the current element and places it in the sorted array at the appropriate location. Selection sort searches the minimum from the unsorted sub-list and replaces it with the current element in hand. How does breadth first traversal works? - ANSTraverse a graph in a breadthwards motion and uses a queue to remember to get the next vertex to start a search when a dead end occurs in any iteration.
How does depth first traversal work? - ANSTraverses a graph in a depthward motion and uses a stack to remember to get the next vertex to start a search when a dead end occurs in any iteration. How does Prim's algorithm works? - ANSTreats the nodes as a single tree and keeps on adding new nodes to the spanning tree from the given graph. How does quick sort work? - ANSDivide and conquer. It divides list in to smaller partitions using a pivot. The values which are smaller than the pivot are arranged on the left parition and the greater values are arranged in the right partition. Each partition is recursively sorted using quick sort. How kruskal's algorithm works? - ANSTreats graph as a forest and every node has an individual tree. A tree connects to another if and only if it has the least cost among all available option and does violate MST properties. How many spanning trees can a graph have? - ANSIt depends on how connected the graph is. A complete undirected graph can have maximum n^n-1 number of spanning trees, where n is the number of nodes. PRACTICE CARD Traverse a binary search tree using: In Order, Pre Order, and Post order traversals. - ANSPRACTICE CARD Traverse a binary search tree using: In Order, Pre Order, and Post order traversals.
Knapsack Problem Job Scheduling Problem What are the 3 primary asymptotic notations? - ANSBest case - Ω(n). Worst case - Ο(n) notation. Average case - Θ(n) notation. What are the criteria of algorithm analysis? - ANSAn algorithm is generally analyzed by two factors -- execution time and space required by the algorithm. What is a binary search tree? - ANSA binary tree with a special provision where a node's left child must have value less than its parent''s value and node's right child must have value greater than it's parent value. What is a binary search? - ANSSearch selects the middle of the list or array and splits it into two parts. First the middle is compared to the target. If it is not found, then a decision must be made to continue the same procedure with either the left or right sub lists. What is a binary tree? - ANSA special tree where each node can have only two children at maximum. What is a bubble sort? How does it work? - ANSA comparison based algorithm in which each pair of adjacent elements is compared and elements are swapped out if they are not in order. Because time complexity is O(n^2), it is not suitable for large sets of data.
What is a data structure? - ANSA way of defining, storing, and retrieving data in a structural and systematic way. What is a graph? - ANSA pictorial representation of a set of object where some pairs of objects are connected by links. The interconnected onect are represented by points called vertices, and the links that connect the vertices are called edges. What is a heap? - ANSSpecial balanced binary tree data structure where root node key is compared with its children and arranged accordingly. A min- heap, a parent node has key value less than its child's and a max heap parent node has value greater than its child's. What is a linear data structure? - ANSA data structure that contains sequentially arranged data items. The next item can be located in the next memory address. Arrays and lists are examples of linear data structures What is a linear search? - ANSA search that attempts to find an item in a sequentially arranged data type. Compared expected data item with each of the data items in a list or array. Average case - O(n) Worst case - O(n^2). Data in target arrays/lists need not to be sorted. What is a linked-list? - ANSA linked-list is a list of data items connected with links ( pointers).
What is an AVL Tree? - ANSHeight balancing binary search tree. CHecks the height of left and right sub-trees and assures that the difference is not more than 1. This is called the balance factor. BalanceFactor = heigh * (left-subtree) - heigh * (right - subtree) What is asymptotic analysis of an algorithm? - ANSRefers to defining the mathematical bounds/framing of an algorithms run-time performance. What is fibonacci series? - ANSGenerates subsequent number by adding two previous numbers. For example. 011235813 What is hashing? - ANSA technique to convert a range of key values into a range of indexes of an array. By using hash tables, we can create an associative data storage where data index can be found by providing its keys. What is insertion sort? - ANSDIvides the list into two sublists, sorted and unsorted. It takes one element at a time and finds its appropriate location in the sorted sublist and inserts it there. The output after insertion is a sorted sublist. What is merge sort and how does it work? - ANSDivide and conquer approach. It keeps dividing the list into smaller sub-lists until all sub-lists are only 1 element big. Then it merges them in a sorted way until all sub-lists are consumed. It has a run-time complexity of O(n log n) and it needs O(n) auxiliary space What is selection sort? - ANSAn in-place sorting technique. It divides the data set into two sublists: sorted and unsorted. Then it selects the minimum
element from unsorted sublist and places it into the sorted list. This iterates unless all the elements from unsorted sublist are consumed. What is shell sort? - ANSShell sort can be said a variant of insertion sort. Shell sort divides the list into smaller sublist based on some gap variable and then each sub-list is sorted using insertion sort. In best cases, it can perform upto Ο(n log n). What is the prefix and post fix notation of (a + b) * (c + d)? - ANS What is the Towers of Hanoi problem? - ANSA mathematical puzzle which consists of three tower pegs and more than one rings. all rings are of different sizes and are stacked upon each other where the lare disk is always below the smaller disk. The aim is to move the tower of disks from one peg to another without breaking its properties. What is tree traversal? - ANSA process to visit all nodes in a tree. Always start from root. Three ways: In-order Traversal Pre-order Traversal Post-order Traversal What operations can be performed on a stack? - ANSpush - add an item to the top of the stack. pop - remove item from the top of the stack. peek - return value stored in the top item without removing it.. isempty