Introduction to Data Structures - Flashcards

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

1/24

flashcard set

Earn XP

Description and Tags

Flashcards covering core concepts from the notes: arrays, memory layouts, pointers, dynamic memory, ADT, data objects, and data structures.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

25 Terms

1
New cards

What is the relationship between Algorithm and Data Structure in programming?

Algorithm + Data Structure = Program.

2
New cards

Define an Array.

A linear data structure that stores homogeneous data items in contiguous memory locations.

3
New cards

What is a Static array?

An array whose size cannot be changed after compilation.

4
New cards

What are the main types of arrays?

Single Dimensional (1-D) arrays and Multi-Dimensional arrays (2-D and n-D).

5
New cards

How is an array declared in C?

datatype arrayname[array_size]; e.g., int A[10];

6
New cards

How are elements of a 1-D array addressed in memory?

Address of ith element = base address + (i × sizeofelement).

7
New cards

What is the base address in an array?

The address of the first element.

8
New cards

How are 1-D array elements stored in memory?

Continuously in memory; contiguous memory locations.

9
New cards

What is a Two-Dimensional array?

An array with m rows and n columns (A[m][n]).

10
New cards

What is the row-major memory addressing formula for a 2-D array?

arr[i][j] = base address + [(i × noofcols + j) × sizeofdata_type].

11
New cards

What is the column-major memory addressing formula for a 2-D array?

arr[i][j] = base address + [(j × noofrows + i) × sizeofdata_type].

12
New cards

What is row-major representation?

All elements stored row-wise in memory; 2-D array viewed as a 1-D array in row-major order.

13
New cards

What is a self-referential structure?

A structure that contains a member which is a pointer to the same type of structure.

14
New cards

Provide an example of a self-referential structure in C.

struct node { int data1; char data2; struct node* link; };

15
New cards

What is a Pointer in C?

A variable that stores the address of another variable; & gives an address; * dereferences to access the value.

16
New cards

What does the malloc() function do?

Allocates a block of memory of a specified size and returns a pointer to the first byte; returns NULL on failure.

17
New cards

What does calloc() do?

Allocates memory for multiple objects of the same size and initializes all bytes to zero; returns pointer or NULL if insufficient memory.

18
New cards

What does free() do?

Releases previously allocated heap memory; the pointer can be reused; do not free elements individually.

19
New cards

What does realloc() do?

Resizes a previously allocated block; may move to a new location; returns a pointer to the new block or NULL on failure; preserves data when possible.

20
New cards

Where is dynamic memory allocated in a C program?

In the heap, separate from the stack and permanent storage area.

21
New cards

What is Abstract Data Type (ADT)?

A data type defined by a logical model with a set of operations and axioms; emphasizes what operations do, not how implemented.

22
New cards

What are advantages of ADT?

Encapsulation, information hiding, implementation hiding, reusability, and reduced complexity.

23
New cards

What are Derived Data Types?

Data types built from primitive types, such as arrays, pointers, structures, and unions.

24
New cards

What is a Data Object?

A runtime instance of a data structure that holds actual values; can be programmer-defined or system-defined.

25
New cards

What is the difference between Linear and Non-Linear Data Structures?

Linear: elements form a sequence (e.g., arrays, lists, stacks, queues). Non-Linear: hierarchical (e.g., trees, graphs).