Docsity

Computer Science — Data Structures and Algorithms. Abstract Data Types, Algorithms, Comple, Exams of Data Structures and Algorithms

Toggle sidebar
bg1
DATA STRUCTURES AND ALGORITHMS PRACTICE
EXAMINATION.
Abstract Data Types, Algorithms, Complexity, Trees, Graphs,
and Searching.
Computer Science — Data Structures and Algorithms.
Questions and Answers.
1. What is a data structure?
Answer: A data structure is a method of organizing and storing data so that it can
be accessed and modified efficiently.
2. What is an abstract data type?
Answer: An abstract data type defines the data and permitted operations without
specifying the implementation details.
3. What is an algorithm?
Answer: An algorithm is a finite sequence of precise instructions for solving a
problem or performing a computation.
4. What are the characteristics of a good algorithm?
Answer: A good algorithm should be correct, finite, unambiguous, effective,
efficient, and applicable to the intended problem.
5. What is algorithm complexity?
Answer: Algorithm complexity measures the computational resources, usually time
or memory, required as input size increases.
6. What is time complexity?
Answer: Time complexity describes how the running time of an algorithm grows
as the size of its input increases.
7. What is space complexity?
pf3
pf4
pf5

Partial preview of the text

Download Computer Science — Data Structures and Algorithms. Abstract Data Types, Algorithms, Comple and more Exams Data Structures and Algorithms in PDF only on Docsity!

DATA STRUCTURES AND ALGORITHMS PRACTICE

EXAMINATION.

Abstract Data Types, Algorithms, Complexity, Trees, Graphs,

and Searching.

Computer Science — Data Structures and Algorithms.

Questions and Answers.

  1. What is a data structure? Answer: A data structure is a method of organizing and storing data so that it can be accessed and modified efficiently.
  2. What is an abstract data type? Answer: An abstract data type defines the data and permitted operations without specifying the implementation details.
  3. What is an algorithm? Answer: An algorithm is a finite sequence of precise instructions for solving a problem or performing a computation.
  4. What are the characteristics of a good algorithm? Answer: A good algorithm should be correct, finite, unambiguous, effective, efficient, and applicable to the intended problem.
  5. What is algorithm complexity? Answer: Algorithm complexity measures the computational resources, usually time or memory, required as input size increases.
  6. What is time complexity? Answer: Time complexity describes how the running time of an algorithm grows as the size of its input increases.
  7. What is space complexity?

Answer: Space complexity describes how much additional memory an algorithm requires as input size increases.

  1. What is Big O notation? Answer: Big O notation describes the upper-bound growth rate of an algorithm’s resource requirements.
  2. What does constant-time complexity mean? Answer: Constant-time complexity, written (O(1)), means the operation takes approximately the same amount of time regardless of input size. 10.What does linear-time complexity mean? Answer: Linear-time complexity, written (O(n)), means running time grows approximately in proportion to input size. 11.What does logarithmic-time complexity mean? Answer: Logarithmic-time complexity, written (O(\log n)), means the problem size is reduced by a constant factor at each major step. 12.What is an array? Answer: An array is an indexed collection of elements stored in a structured sequence, commonly in contiguous memory. 13.State one advantage of arrays. Answer: Arrays provide efficient direct access to elements using an index. 14.State one disadvantage of arrays. Answer: Fixed-size arrays may require costly resizing or may waste space, while insertion and deletion can require shifting elements. 15.What is a linked list? Answer: A linked list is a sequence of nodes in which each node stores data and a reference to another node.

25.What is recursion? Answer: Recursion is a technique in which a function calls itself to solve smaller versions of a problem. 26.What is a base case? Answer: A base case is the condition that stops recursive calls. 27.What is sorting? Answer: Sorting is arranging data according to a specified order, such as ascending or descending order. 28.What is bubble sort? Answer: Bubble sort repeatedly compares adjacent elements and swaps them when they are in the wrong order. 29.What is selection sort? Answer: Selection sort repeatedly selects the smallest or largest remaining element and places it in its correct position. 30.What is insertion sort? Answer: Insertion sort builds a sorted portion by inserting each new element into its appropriate position. 31.What is merge sort? Answer: Merge sort divides data into smaller parts, sorts them recursively, and merges the sorted parts. 32.What is quicksort? Answer: Quicksort selects a pivot, partitions data around the pivot, and recursively sorts the resulting subarrays. 33.What is linear search?

Answer: Linear search examines elements sequentially until the target is found or the collection is exhausted. 34.What is binary search? Answer: Binary search repeatedly divides a sorted collection into halves to locate a target efficiently. 35.What requirement does binary search have? Answer: The collection must generally be sorted before binary search is used. 36.What is a tree? Answer: A tree is a hierarchical data structure consisting of nodes connected by edges and organized around a root. 37.What is a binary tree? Answer: A binary tree is a tree in which each node has at most two children. 38.What is a binary search tree? Answer: A binary search tree maintains an ordering in which smaller values are placed to one side and larger values to the other. 39.What is tree traversal? Answer: Tree traversal is the process of visiting every node in a specified order. 40.Name three depth-related tree traversals. Answer: Preorder, inorder, and postorder traversals are common depth-first tree traversals. 41.What is a heap? Answer: A heap is a complete or nearly complete tree satisfying a defined ordering property, such as the min-heap or max-heap property. 42.What is a graph?