Data Structures and Algorithms
24 Questions
2 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which of the following algorithms has a worst-case time complexity of O(n^2)?

  • Heap Sort
  • Merge Sort
  • Counting Sort
  • Insertion Sort (correct)
  • Merge Sort is an example of an in-place sorting algorithm.

    False

    Name one linear data structure.

    array

    The worst-case time complexity of Quick Sort is O(____).

    <p>n^2</p> Signup and view all the answers

    Match the following algorithms with their time complexities:

    <p>Insertion Sort = O(n^2) Binary Search = O(log n) Depth First Search = O(|V| + |E|) Dijkstra's Algorithm = O(V log V + E)</p> Signup and view all the answers

    Which of the following algorithms utilize the divide and conquer paradigm?

    <p>Merge Sort</p> Signup and view all the answers

    An unbalanced binary search tree has a worst-case time complexity of O(log n).

    <p>False</p> Signup and view all the answers

    Provide an example of a stable sorting algorithm.

    <p>Merge Sort</p> Signup and view all the answers

    Which of the following is NOT a reason for using dynamic programming?

    <p>Ignoring memory storage requirements</p> Signup and view all the answers

    Dynamic programming incurs a time-memory trade-off.

    <p>True</p> Signup and view all the answers

    What type of algorithm is used to calculate the minimum number of scalar products?

    <p>Matrix-chain multiplication</p> Signup and view all the answers

    The ___ table is used to store the lengths of various subproblems in the LCS algorithm.

    <p>C</p> Signup and view all the answers

    What is true about a stable sorting algorithm?

    <p>The output array preserves the order of equal elements.</p> Signup and view all the answers

    Match the following arrow directions with their meanings in LCS:

    <p>Diagonal Arrow = Current characters match and are part of the LCS Up Arrow = Current character of first sequence is not part of the LCS Left Arrow = Current character of second sequence is not part of the LCS</p> Signup and view all the answers

    In a max-heap, A[Parent(i)] is less than or equal to A[i].

    <p>False</p> Signup and view all the answers

    What is stored in the B table of the LCS?

    <p>The directional information for reconstructing the LCS</p> Signup and view all the answers

    B-trees are designed for use primarily in main memory applications.

    <p>False</p> Signup and view all the answers

    What are the names of the two functions used to add and remove elements from a stack?

    <p>Push and Pop</p> Signup and view all the answers

    What is the output of the LCS algorithm?

    <p>The length of the longest common subsequence and the subsequence itself</p> Signup and view all the answers

    The best case time complexity for Quicksort occurs when the pivot divides the array _ into half.

    <p>nearly</p> Signup and view all the answers

    Match the following traversal types with their output order:

    <p>Inorder = 25, 30, 35, 40, 45, 50, 60 Preorder = 40, 30, 25, 35, 50, 45, 60 Postorder = 25, 35, 30, 45, 60, 50, 40</p> Signup and view all the answers

    What policy does a queue use?

    <p>First in First Out</p> Signup and view all the answers

    Chaining is a method used to resolve collisions in hash tables.

    <p>True</p> Signup and view all the answers

    List the three arrays used in Counting-Sort and their purposes.

    <p>A - input array, B - output array, C - auxiliary array</p> Signup and view all the answers

    Study Notes

    Algorithm Time Complexities

    • Insertion Sort: Worst case time complexity is O(n^2).
    • Merge Sort: Worst case time complexity is O(n log n).
    • Heap Sort: Worst case time complexity is O(n log n).
    • Quick Sort: Worst case time complexity is O(n^2). Best case time complexity is O(n log n).
    • Counting Sort: Worst case time complexity is O(k + n), where k is the range of input values.
    • Searching Hash Table: Worst case time complexity is O(n).

    Data Structures

    Linear Data Structures

    • Array
    • Stack
    • Queue
    • Linked List

    Non-linear Data Structures

    • Tree
    • Graph
    • Hash Table

    Sorting Algorithms

    Stable vs. Unslable Sorting

    • Stable sorting: Maintains the relative order of elements with equal values. Examples include Merge Sort.
    • Unstable sorting: Does not maintain the relative order of equal elements. Examples include Quick Sort.

    Divide and Conquer Algorithms

    • Quicksort
    • Merge Sort
    • Binary Search

    Binary Search Tree Property

    • If a node y is in the left subtree of node x, then y's key is less than or equal to x's key.
    • If a node y is in the right subtree of node x, then y's key is greater than or equal to x's key.

    Tree Attributes

    • Root
    • Parent
    • Child
    • Leaf
    • Edge
    • Key

    Red-Black Tree Properties

    • Every node is either red or black.
    • The root is black.
    • Every leaf (NIL) is black.
    • If a node is red, then both its children are black.
    • For each node, all simple paths from the node to descendant leaves contain the same number of black nodes.

    Sentinel

    • A sentinel is a special value used as a boundary condition for algorithms like merge sort.

    Chaining (Hash Tables)

    • A technique to handle collisions in hash tables by placing elements with the same hash value in a linked list.

    Dynamic Programming

    • Breaks down a problem into smaller overlapping subproblems to optimize resource utilization.
    • Uses a table to store the solutions to these subproblems to avoid redundant computations.
    • Used for optimization problems.

    Graph Traversal Algorithms

    • Depth-First Search (DFS)
    • Breadth-First Search (BFS)

    Strongly Connected Components (SCC)

    • A strongly connected component in a graph is a maximal set of vertices such that for any two vertices u and v in the component, there is a path from u to v and a path from v to u.

    Minimum Spanning Tree (MST) Algorithms

    • Prim's Algorithm
    • Kruskal's Algorithm

    Dijkstra's Algorithm

    • Finds the shortest paths from a single source vertex to all other vertices in a graph with non-negative edge weights.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Description

    This quiz covers fundamental concepts related to data structures, sorting algorithms, and their time complexities. Explore insertion sort, merge sort, quicksort, and various data structures like arrays, trees, and hash tables. Test your understanding of stability in sorting and the divide and conquer strategy.

    More Like This

    Data Structure and Algorithms Quiz
    9 questions
    Sorting Algorithms Overview
    12 questions
    Algorithm Time Complexities Quiz
    29 questions
    Algorithm Time Complexities Quiz
    53 questions
    Use Quizgecko on...
    Browser
    Browser