Abstract Data Types and Data Structures Overview Cartes | Quizlet

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/239

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

240 Terms

1
New cards

Abstract Data Type (ADT)

A type (or class) for objects whose behavior is defined by a set of values and a set of operations.

<p>A type (or class) for objects whose behavior is defined by a set of values and a set of operations.</p>
2
New cards

Abstraction

The process of providing only the essentials and hiding the details.

3
New cards

List ADT

A list contains elements of the same type arranged in sequential order.

4
New cards

get()

Return an element from the list at any given position.

5
New cards

insert()

Insert an element at any position of the list.

6
New cards

remove()

Remove the first occurrence of any element from a non-empty list.

7
New cards

removeAt()

Remove the element at a specified location from a non-empty list.

8
New cards

replace()

Replace an element at any position by another element.

9
New cards

size()

Return the number of elements in the list.

10
New cards

isEmpty()

Return true if the list is empty, otherwise return false.

11
New cards

isFull()

Return true if the list is full, otherwise return false.

12
New cards

Stack ADT

A Stack contains elements of the same type arranged in sequential order.

13
New cards

push()

Insert an element at one end of the stack called top.

<p>Insert an element at one end of the stack called top.</p>
14
New cards

pop()

Remove and return the element at the top of the stack, if it is not empty.

<p>Remove and return the element at the top of the stack, if it is not empty.</p>
15
New cards

peek()

Return the element at the top of the stack without removing it, if the stack is not empty.

16
New cards

size()

Return the number of elements in the stack.

17
New cards

isEmpty()

Return true if the stack is empty, otherwise return false.

18
New cards

isFull()

Return true if the stack is full, otherwise return false.

19
New cards

Queue ADT

A Queue contains elements of the same type arranged in sequential order.

20
New cards

enqueue()

Insert an element at the end of the queue.

<p>Insert an element at the end of the queue.</p>
21
New cards

dequeue()

Remove and return the first element of the queue, if the queue is not empty.

22
New cards

peek()

Return the element of the queue without removing it, if the queue is not empty.

23
New cards

size()

Return the number of elements in the queue.

24
New cards

isEmpty()

Return true if the queue is empty, otherwise return false.

25
New cards

isFull()

Return true if the queue is full, otherwise return false.

26
New cards

Data Structure

A specialized format for organizing, processing, retrieving and storing data.

27
New cards

Advantages of Data Structure

Data structures allow information storage on hard disks, management of large datasets, design of efficient algorithms, safe storage of information, and easier processing of data.

28
New cards

Data Structures

A way to organize and store data in a computer so that it can be accessed and modified efficiently.

29
New cards

Arrays

An array stores a collection of items at adjoining memory locations, allowing easy calculation or retrieval of each element.

30
New cards

Stacks

A stack stores a collection of items in a linear order, following the last in first out (LIFO) principle.

31
New cards

Queues

A queue stores a collection of items where the operation order is first in first out (FIFO).

32
New cards

Linked Lists

A linked list stores a collection of items in a linear order, where each node contains a data item and a reference to the next item.

33
New cards

Trees

A tree stores a collection of items in a hierarchical way, with nodes linked to other nodes and possibly having multiple children.

34
New cards

Graphs

A graph stores a collection of items in a non-linear fashion, made up of nodes (vertices) and edges connecting them.

35
New cards

Linear Data Structures

Data structures where data items are arranged in a linear sequence, such as arrays.

36
New cards

Non-Linear Data Structures

Data structures where data items are not in sequence, such as trees and graphs.

37
New cards

Homogeneous Data Structures

Data structures where all elements are of the same type, such as arrays.

38
New cards

Non-Homogeneous Data Structures

Data structures where elements may or may not be of the same type.

39
New cards

Static Data Structures

Data structures whose sizes and memory locations are fixed at compile time, such as arrays.

40
New cards

Dynamic Data Structures

Data structures that can expand or shrink depending on program needs, such as linked lists.

41
New cards

Stack Data Structure

An Abstract Data Type (ADT) that follows a particular order for operations, typically LIFO.

42
New cards

Push Operation

The procedure of inserting a new element to the top of the stack.

43
New cards

Stack Overflow

An attempt to insert a new element into a full stack, resulting in an overflow condition.

44
New cards

Pop Operation

The procedure of removing an element from the top of the stack.

45
New cards

Peek or Top

Returns the top element of the stack.

46
New cards

isEmpty

Returns true if the stack is empty, else false.

47
New cards

isFull

Checks if the stack is full.

48
New cards

Stack Underflow

Any attempt to delete an element from already empty stack results into Stack Underflow.

49
New cards

Push Operation

The process of putting a new data element onto stack.

50
New cards

Steps of Push Operation

1. Checks if the stack is full. 2. If the stack is full, produces an error and exit. 3. If the stack is not full, increments top to point next empty space. 4. Adds data element to the stack location, where top is pointing. 5. Returns success.

51
New cards

Algorithm for Push Operation

begin procedure push: stack, data; if stack is full return null; top ← top + 1; stack[top] ← data; end procedure

52
New cards

Pop Operation

Accessing the content while removing it from the stack.

53
New cards

Steps of Pop Operation

1. Checks if the stack is empty. 2. If the stack is empty, produces an error and exit. 3. If the stack is not empty, accesses the data element at which top is pointing. 4. Decreases the value of top by 1. 5. Returns success.

54
New cards

Algorithm for Pop Operation

begin procedure pop: stack; if stack is empty return null; data ← stack[top]; top ← top - 1; return data; end procedure

55
New cards

peek()

Get the top data element of the stack, without removing it.

56
New cards

Algorithm of peek() function

begin procedure peek; return stack[top]; end procedure

57
New cards

isempty()

Check if stack is empty.

58
New cards

Algorithm of isempty() function

begin procedure isempty; if top less than 1 return true; else return false; end procedure

59
New cards

isfull()

Check if stack is full.

60
New cards

Algorithm of isfull() function

begin procedure isfull; if top equals to MAXSIZE return true; else return false; end procedure

61
New cards

Applications of stack

Infix to Postfix/Prefix conversion, Redo-undo features at many places like editors, photoshop, Forward and backward feature in web browsers, Used in many algorithms like Tower of Hanoi, tree traversals, stock span problem, histogram problem.

62
New cards

Implementation of Stack

There are two ways to implement a stack: Using array, Using linked list.

63
New cards

MAX

Defined as 5 in the stack implementation program.

64
New cards

top

An integer variable initialized to -1 indicating the current position in the stack.

65
New cards

Stack Overflow

Occurs when trying to push an element onto a full stack.

66
New cards

C Program Structure

Includes standard libraries, defines MAX, initializes stack and top, and contains main function with a loop for stack operations.

67
New cards

Menu Options

1. Push, 2. Pop, 3. Display, 4. Exit.

68
New cards

Push Function

Prompts user for an element to push onto the stack and updates the stack accordingly.

69
New cards

Display Function

Not explicitly defined in the notes but implied to show stack contents.

70
New cards

pop()

A function that removes the top element from the stack.

71
New cards

Stack Underflow

An error that occurs when trying to pop an element from an empty stack.

72
New cards

display()

A function that prints all elements in the stack.

73
New cards

Expression

A collection of operators and operands that represents a specific value.

74
New cards

Operator

A symbol that performs a particular task like arithmetic, logical, or conditional operation.

75
New cards

Operand

The values on which the operators can perform tasks, which can be direct values, variables, or addresses.

76
New cards

Infix Expression

An expression where the operator is placed between the operands.

77
New cards

Postfix Expression

An expression where the operator is placed after the operands.

78
New cards

Prefix Expression

An expression where the operator is placed before the operands.

79
New cards

Infix to Postfix Conversion

The process of converting an infix expression into a postfix expression using a stack.

80
New cards

Infix to Prefix Conversion

The process of converting an infix expression into a prefix expression.

81
New cards

Stack Data Structure

A data structure that follows the Last In First Out (LIFO) principle.

82
New cards

Higher or Equal Precedence

Refers to operators that have the same or greater priority than the current operator in expression evaluation.

83
New cards

Final Postfix Expression

The result of converting an infix expression into postfix notation.

84
New cards

Example of Infix Expression

( A + B ) * ( C - D )

85
New cards

Example of Final Postfix Expression

A B + C D - *

86
New cards

Example of Infix Expression with Exponent

A + (B C - (D / E ^ F) G) * H

87
New cards

Left Parenthesis

The symbol '(' used in expressions to denote the start of a sub-expression.

88
New cards

Right Parenthesis

The symbol ')' used in expressions to denote the end of a sub-expression.

89
New cards

Push

To add an element to the top of the stack.

90
New cards

Pop

To remove the top element from the stack.

91
New cards

Print

To output a value or message to the console.

92
New cards

Symbol

Any character that represents an operator or operand in an expression.

93
New cards

Result (Output)

The final output after processing an expression.

94
New cards

Infix to Prefix Conversion

A method that involves reversing the input string before conversion and then reversing the final output string before displaying it.

95
New cards

Step 1

Reverse the infix expression i.e A+BC will become CB+A. Note while reversing each '(' will become ')' and each ')' becomes '('.

96
New cards

Step 2

Obtain the postfix expression of the reversing expression i.e CB*A+.

97
New cards

Step 3

Reverse the postfix expression. Hence in our example prefix is +A*BC.

98
New cards

Example Expression

Infix expression = (A+B^C)*D+E^5.

99
New cards

Step 1 Example

Reverse the infix expression: 5^E+D*(C^B+A).

100
New cards

Step 3 Example

Convert expression to postfix form: (5^E+D*(C^B+A)).