Midterm exam Data Structure

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/60

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:37 PM on 9/2/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

61 Terms

1
New cards

Abstraction

The process of hiding unnecessary details and showing only the essential features of an object or system.

In simple terms: You know what something does, but you don't need to know how it works internally.

Everyday Example:

🚗 Driving a Car

When you drive a car, you use:

• Steering wheel

• Accelerator

• Brake

You do not need to know how the engine, transmission, or fuel injection system works. You only use the controls.

2
New cards

Abstract Data Type (ADT)

A logical description of a data structure.

It defines:

• What operations can be performed

• Not how those operations are implemented

Think of it as a blueprint or set of rules.

3
New cards

Push

Add an Item

4
New cards

Pop

Remove the top item

5
New cards

Peek

View the top item

6
New cards

isEmpty

Check if the stack is empty

7
New cards

Stack

Follows the Last In, First Out (LIFO) principle

Imagine a stack of plates:

🍽 Plate 3 (Top)

🍽 Plate 2

🍽 Plate 1 (Bottom)

You can only:

• Put a plate on top

• Remove the top plate

8
New cards

Queue

Follows First In, First Out (FIFO) principle.

Example:

People waiting to buy movie tickets.

John → Maria → Alex

  • John entered first.

  • John will be served first.


9
New cards

Enqueue

Add to the rear

10
New cards

Dequeue

Remove from the front

11
New cards

Front

View the first person

12
New cards

Linear and Non-Linear

Two types of Data Structure

13
New cards

Linear

Elements are accessed in a sequential order but may be stored unsystematically.

14
New cards

Non-Linear

Elements are stored and accessed in a non-sequential order.

15
New cards

Linked List

Used for storing elements where each is a separate object.

16
New cards

Tree

Represents a hierarchical nature of a structure in a graphical form

17
New cards

Priority Queue

Used for retrieving and removing either the minimum or maximum element.

18
New cards

Heap

A partially sorted binary tree.

19
New cards

Set

Represents a collection of elements that do not have to be in order.

20
New cards

Map

A set of ordered pairs with elements known as key and value.

21
New cards

Graph

Consists of a set of points/nodes (vertices) and set of links (edges) which connects the pairs of vertices.

22
New cards

Algorithm

A clear, step-by-step procedure used to solve a problem or complete a task. Similar to a cooking recipe. A recipe provides instructions that must be followed in the correct order.

Everyday example: Making coffee

1. Prepare a cup.

2. Put coffee into the cup.

3. Add hot water.

4. Add sugar and milk.

5. Stir the coffee.

6. Serve.

23
New cards

Characteristics of a Good Algorithm

Finiteness, Definiteness, Input, Output, and Uniqueness or Effectiveness

24
New cards

Finiteness

The algorithm must stop after completing a limited number of steps.

Example:

1. Enter two numbers.

2. Add the numbers.

3. Display the result.

4. End. The algorithm has an ending.

25
New cards

Definiteness

Every instruction must be clear and understandable.

Clear instruction:

Add the first number and the second number.

26
New cards

Input

The information received by the algorithm before processing begins.

Example:

In a grading system, the inputs may be:

Student name: Ana

Quiz grade: 90

Exam grade: 85

An algorithm may have one ___, several ____, or sometimes no ____.

27
New cards

Output

The result produced by the algorithm.

Using the grades above:

Average: 87.5

The average is the ____.

28
New cards

Uniqueness or Effectiveness

Every step must produce an expected result based on the input or the result of a previous step.

Example:

Input: 10 and 5

Process: 10 + 5

Output: 15

The process should consistently produce the correct answer.

29
New cards

Elements of an Algorithm

Sequential Operations, Selection or Decision, Iteration, and Recursion

30
New cards

Sequential Operations

Are instructions performed one after another.

Example:

Calculating a rectangle’s area

1. Enter the length.

2. Enter the width.

3. Multiply the length by the width.

4. Display the area.

If:

Length = 5

Width = 4

Then:

Area = 5 × 4

Area = 20

31
New cards

Selection or Decision

Allows the algorithm to choose an action based on a condition. It normally uses an if statement.

Example: Passing or failing

If grade is 75 or higher

Display "Passed"

Otherwise

Display "Failed"

If the grade is 80, the output is: Passed

32
New cards

Iteration

Means repeating an instruction several times. It is also called a loop.

Example:

Display the numbers from 1 to 5:

1

2

3

4

5

The display instruction is repeated five times.

33
New cards

Recursion

Happens when a method calls itself to solve a smaller version of the same problem.

34
New cards

Algorithm Design Paradigms

A general approach used to solve a problem.

35
New cards

Brute Force Algorithm

Tries possible answers until it finds the correct one.

36
New cards

Divide and Conquer

Breaks a large problem into smaller problems. It usually follows three actions:

1. Divide the problem.

2. Solve each smaller problem.

3. Combine the answers.

37
New cards

Dynamic Programming

Saves previously calculated results so the computer does not need to calculate them again.

38
New cards

Greedy Algorithm

Chooses the option that provides the best immediate benefit.

39
New cards

Sorting Algorithm

Arranges data in a particular order.

40
New cards

Ascending order

The values are arranged from smallest to largest.

Original list: 5, 8, 1, 2, 20

Sorted list: 1, 2, 5, 8, 20

41
New cards

Descending order

The values are arranged from largest to smallest.

20, 8, 5, 2, 1

42
New cards

Alphabetical order

Names may be sorted from A to Z:

Cruz, Dela Rosa, Garcia, Reyes, Santos

43
New cards

Bubble Sort

Compares two neighboring values. If they are in the wrong order, the values exchange positions.

The biggest value slowly moves toward the end of the list, similar to a bubble rising to the surface.

44
New cards

Selection Sort

Finds the smallest value in the unsorted part of the array. It then places that value in the next correct position.

45
New cards

Insertion Sort

Takes one value at a time and inserts it into the correct position in the sorted part of the list. It is similar to arranging playing cards in your hand.

46
New cards

Searching Algorithms

• Is a basic, fundamental step in computing done via step-by-step method to locate a specific data among a collection of data.

• All ______ make use of a search key in order to complete the procedure, and they are expected to return a success or a failure status (in boolean true or false value).

• It is designed to check or retrieve an element from any data structure where it is being stored.

47
New cards

Linear Search

Or sequential search is a method for finding an element within a list. This type of searching algorithms sequentially checks each element of the list until a match is found or the whole list has been searched.

Examines the elements one at a time.

Given: 12, 7, 20, 5, 9

Find 5.

Process:

1. Check 12 — not equal to 5.

2. Check 7 — not equal to 5.

3. Check 20 — not equal to 5.

4. Check 5 — found.

48
New cards

Binary Search

Used to find the position of a specific value contained in a sorted array. The critical part of this strategy is that the list must be in order. This can be implemented only on a sorted list of items. If the elements are not sorted already, we need to sort them first.

49
New cards

Jump Search

The fundamental idea behind this searching technique is to search fewer number of elements compared to linear search algorithm. This can be done by skipping some fixed number of array elements or jumping ahead by fixed number of steps in every iteration.

50
New cards

Data Field

This contains the value of the element

51
New cards

Pointer field (link or reference)

This contains the address (random memory location) of the next node.

52
New cards

HEAD

The first node in the list is called ______.

53
New cards

NULL

The last node points to _____ since there are no more successive elements.

54
New cards

Singly Linked List

The basic linked list. Each node has data and an address field that contains a reference to the next node.

55
New cards

Doubly Linked List

Contains an extra pointer to connect to the previous node in the sequence. The left pointer contains the address of the preceding node called “predecessor.”

56
New cards

Circular Linked List

A linked list in which the last node’s right pointer contains the address of the first node.

57
New cards

Display

shows the elements in the list

58
New cards

Insert

adds an element into the list

59
New cards

Delete

removes a specific element or all the elements from the list

60
New cards

Search

finds a specific element in the list

61
New cards

Count

returns the number of elements in the list