You are on page 1of 8

KAMPALA UNIVERSITY

We strive for excellence

NAME : NSWADI WILLIAM GEORGE

REG NO : 21/KUA/BCSIT/261U

COURSE : BCSIT

COURSE UNIT : DATA STRUCTURES C++

YEAR : THREE

SEMESTER : ONE

LECTURER : MR. KAWEESA ALEX

QUESTIONS :
1. What is Data Structure? Explain.
2. List the area of applications of Data Structure.
3. What is the difference between file structure and storage structure?
4. List the data structures which are used in RDBMS, Network Data Modal,
and Hierarchical Data Model.
5. List the area of applications where stack data structure can be used?
6. What is the difference between PUSH and POP?
7. What is a postfix expression?
ANSWERS

1. What is Data Structure? Explain.


A data structure is a collection of data values and the relationships between
them. Data structures allow programs to store and process data effectively.
There are many different data structures, each with its own advantages and
disadvantages. Some of the most common data structures are arrays, lists, trees,
and graphs.

Need of Data Structure

As applications are becoming more complex and the amount of data is


increasing day by day, which may cause problems with processing speed,
searching data, handling multiple requests etc. Data structure provides a way of
organizing, managing, and storing data efficiently. With the help of data
structure, the data items can be traversed easily. Data structure provides
efficiency, reusability and abstraction. It plays an important role in enhancing
the performance of a program because the main function of the program is to
store and retrieve the user’s data as fast as possible.

Data structure and algorithms are two of the most important aspects of computer
science. Data structures allow us to organize and store data, while algorithms
allow us to process that data in a meaningful way. Learning data structure and
algorithms will help you become a better programmer. You will be able to write
code that is more efficient and more reliable. You will also be able to solve
problems more quickly and more effectively.

Types of Data Structure

There are 2 types of Data Structure :

 Primitive Data Structure


 Non – Primitive Data Structure

Primitive Data Structure –

Primitive Data Structures directly operate according to the machine instructions.


These are the primitive data types. Data types like int, char, float, double, and
pointer are primitive data structures that can hold a single value.
Non – Primitive Data Structure

Non-primitive data structures are complex data structures that are derived from
primitive data structures. Non – Primitive data types are further divided into two
categories.

 Linear Data Structure


 Non – Linear Data Structure
Linear Data Structure –

Linear Data Structure consists of data elements arranged in a sequential manner


where every element is connected to its previous and next elements. This
connection helps to traverse a linear arrangement in a single level and in a
single run. Such data structures are easy to implement as memory is additionally
sequential. Some examples of Linear Data Structure are List, Queue, Stack,
Array etc.

Types of Linear Data Structure

Arrays
An array is a collection of similar data elements stored at contiguous memory
locations. It is the simplest data structure where each data element can be
accessed directly by only using its index number.

Linked List
A linked list is a linear data structure that is used to maintain a list-like structure
in the computer memory. It is a group of nodes that are not stored at contiguous
locations. Each node of the list is linked to its adjacent node with the help of
pointers.

Stack
Stack is a linear data structure that follows a specific order during which the
operations are performed. The order could be FILO (First In Last Out) or LIFO
(Last In First Out).
The basic operations performed in stack are as follows :

 Push – Adds an item within the stack.


 Pop – Deletes or removes an item from the stack.
 Top – Returns the topmost element of the stack.
 IsEmpty – Returns true if the stack is empty.
Queue

Queue is a linear data structure in which elements can be inserted from only one
end which is known as rear and deleted from another end known as front. It
follows the FIFO (First In First Out) order.

 Deque – Adds an element to the queue.


 Enqueue – Deletes or removes an element from the queue.
 IsFull – Returns true if the queue is full.
 IsEmpty – Returns true if the queue is empty.

Non-Linear Data Structure –

Non-linear Data Structures do not have any set sequence of connecting all its
elements and every element can have multiple paths to attach to other elements.
Such data structures support multi-level storage and sometimes can’t be
traversed in a single run.

Types of Non-Linear Data Structure

 Tree

A tree is a multilevel data structure defined as a set of nodes. The topmost node
is named root node while the bottom most nodes are called leaf nodes. Each
node has only one parent but can have multiple children.

Types of Trees in Data structure

 General Tree
 Binary Tree
 Binary Search Tree
 AVL Tree
 Red Black Tree
 N-ary Tree
 Graph

A graph is a pictorial representation of a set of objects connected by links


known as edges. The interconnected nodes are represented by points named
vertices, and the links that connect the vertices are called edges.
Types of Graph

 Finite Graph  Bipartite Graph


 Infinite Graph  Labeled Graph
 Trivial Graph  Diggraph Graph
 Simple Graph  Subgraph
 Multi Graph  Connected or Disconnected
 Null Graph Graph
 Complete Graph  Cyclic Graph
 Pseudo Graph  Vertex Labelled Graph
 Regular Graph  Directed Acyclic Graph
A graph is a pair of sets (V, E), where V is the set of vertices and E is the set of
edges.

Data Structure can be further classified as

 Static Data Structure


 Dynamic Data Structure
Static Data Structure

Static Data Structures are data structures where the size is allocated at the
compile time. Hence, the maximum size is fixed and cannot be changed.

Dynamic Data Structure

Dynamic Data Structures are data structures where the size is allocated at the
run time. Hence, the maximum size is flexible and can be changed as per
requirement.

Data Structure Operations –


The common operations that can be performed on the data structures are as
follows :
 Searching – We can easily search for any data element in a data structure.

 Sorting – We can sort the elements either in ascending or descending


order.
 Insertion – We can insert new data elements in the data structure.

 Deletion – We can delete the data elements from the data structure.

 Updation – We can update or replace the existing elements from the data
structure.
Advantages of Data Structure –
 Data structures allow storing the information on hard disks.
 An appropriate choice of ADT (Abstract Data Type) makes the program
more efficient.
 Data Structures are necessary for designing efficient algorithms.
 It provides reusability and abstraction.
 Using appropriate data structures can help programmers save a good
amount of time while performing operations such as storage, retrieval, or
processing of data.
 Manipulation of large amounts of data is easier.

2. List the area of applications of Data Structure.


Data Structure Applications

 Organization of data in a computer’s memory


 Representation of information in databases
 Algorithms that search through data (such as a search engine)
 algorithms that manipulate data (such as a word processor)
 algorithms that analyze data (such as a data miner)
 algorithms that generate data (such as a random number generator)
 algorithms that compress and decompress data (such as a zip utility)
 algorithms that encrypt and decrypt data (such as a security system)
 software that manages files and directories (such as a file manager)
 software that renders graphics (such as a web browser or 3D rendering
software)

3. What is the difference between file structure and storage structure?


The key difference between both the data structure is the memory area that is
being accessed. When dealing with the structure that resides the main memory
of the computer system, this is referred to as storage structure. When dealing
with an auxiliary structure, we refer to it as file structures.
4. List the data structures which are used in RDBMS, Network Data
Modal, and Hierarchical Data

 RDBMS - Array (i.e. Array of structures)


 Network data model- Graph
 Hierarchical data model - Trees

 Array of structures is used majorly in RDBMS so that the data is maintained


properly.
 A database model that permits numerous records to be linked to the same owner
file is known as a network database model. The Data Model for Spatial and
Graph Networks For vast, complex networks, the graph feature can be used.
 A hierarchical database model is one in which the information is structured in a
tree-like structure. The information is kept in the form of records that are linked
together.

5. List the area of applications where stack data structure can be used?

A Stack is a linear data structure that holds a linear, ordered sequence of


elements. It is an abstract data type.To implement the Stack, it is required to
maintain a pointer to the top of the Stack, which is the last element to be
inserted because we can access the elements only on the top of the Stack.

A Stack can be used for evaluating expressions consisting of operands and


operators.
Stacks can be used for Backtracking, i.e., to check parenthesis matching in an
expression.
It can also be used to convert one form of expression to another form.
It can be used for systematic Memory Management.
6. What is the difference between PUSH and POP?

. PUSH: PUSH operation implies the insertion of a new element into a


Stack

POP means to delete an element from the Stack. Before


 . PUSH adds an item to the top of a stack, while POP removes the top
item from a stack.
 PUSH is typically used to add data to a stack, while POP is used to
remove data from a stack.
 PUSH can be used to add an item to a stack, and then POP can be used
to remove the item from the top of the stack.
 stack.

7. What is a postfix expression?


The way to write arithmetic expression is known as a notation. An arithmetic
expression can be written in three different but equivalent notations i.e.,
without changing the essence or output of an expression. These notations are –
 Infix
 Prefix
 Postfix

You might also like