Sonzaschool
Back

O-Level · Secondary 3

ICT

Types of Data Structures

about 5 minutes to read

Discussions
Topics in this sectionData Structures1 topic
  1. Types of Data Structures

When we write programs to solve problems, we need a way to store and organize information. A data structure is a particular way of organizing and storing data in a computer so that it can be accessed and used efficiently. Choosing the right data structure makes our programs faster and easier to write.

Data structures are divided into two main groups based on how the data is arranged: linear data structures and nonlinear data structures.

In a linear data structure, data elements are arranged in a sequence — one after another, like people standing in a line at a boma market. Each element connects to the one before it and the one after it. You can traverse all elements in one pass.

The main types of linear data structures are arrays, linked lists, stacks, and queues.

Array

An array is a collection of items stored at adjacent memory locations. Think of it like a row of numbered rooms in a hotel — each room has an index number, and you can go directly to any room if you know its number.

For example, if we store the ages of five students in an array, it might look like this in a program:

ages = [14, 15, 14, 16, 15]

The first student's age is at position 0, the second at position 1, and so on. Arrays let you access any element quickly if you know its position.

Linked List

A linked list is like a treasure hunt — each item contains data AND a pointer to the next item in the sequence. To find a particular item, you must start at the beginning and follow the chain.

Unlike arrays, linked lists can grow or shrink easily during program execution. Each element is called a node.

Stack

A stack works like a stack of plates in a school dining hall. You add new items to the top, and you can only remove items from the top. This is called Last In, First Out (LIFO).

In programming, stacks are used when you need to undo actions — for example, when you press the back button in a web browser, the browser remembers the pages you visited using a stack.

Queue

A queue works like people waiting for a shared taxi in Juba. The first person to arrive is the first to get in. This is called First In, First Out (FIFO).

Queues are used in real-world situations like printing documents — the first document sent to the printer is the first one printed.

Question

What are the two main groups into which data structures are divided?

Sign in to submit your answer and have it count toward your mastery.

Sign in to practice

Tutor

Stuck? Ask me anything about this topic.

Sign in to ask the Sonza AI Tutor about this question.

Sign in to ask

Discussions

No questions yet

Sign in to ask
Loading discussions…