You are on page 1of 17

CSE205

Data Structures And Algorithms

Lecture #1
Basic Data Structures
By: Mohammad Shabaz
Introduction
• What is Data Structure?
Data Structure is defined as implementation
of ADT(Abstract Data Type).
• What is ADT?
Collection of values and Operation perform on it.
An ADT, is a logical description of how we view
the data and the operations that are allowed
without regard to how they will be
implemented.
How is ADT differs from DT.
Abstract Data Types Data Types

The logical representation of The physical representation of


memory. memory.

Can be created and modified by Fixed and Predefined and are


user. unable to modify.

Lists, Stack, Queue, Trees, Integer, character, float, pointer,


Graphs. array.
When ADT Becomes DS?
• The implementation of an abstract data type,
often referred to as a data structure, will
require that we provide a physical view of the
data using some collection of programming
constructs and primitive data types.
• Those ADT’s which are build and programmed
can became Data Structure.
How ADT looks like?
Figure 1 shows a picture of what an abstract
data type is and how it operates. The user
interacts with the interface, using the
operations that have been specified by the
abstract data type. The abstract data type is the
shell that the user interacts with. The
implementation is hidden one level deeper. The
user is not concerned with the details of the
implementation.

Figure 1: Abstract Data Type


Some example of ADT:
• Stack- Works in first in last out order. The
element inserted first in stack is removed last.
• Queue- First in First out order. The element
inserted first is removed first.
• Linked list- Stored data in a linear fashion.
• Trees- Stores data in a non linear fashion with
one root node and sub nodes.
Types of Data Structures
• Linear data structure: A linear data structure
traverses the data elements sequentially, in
which only one data element can directly be
reached. Ex: Linked Lists.
• Non-Linear data structure: Every data item
is attached to several other data items in a
way that is specific for reflecting
relationships. The data items are not
arranged in a sequential structure. Ex: Trees,
Graphs
Operations on Data Structures

• Traversing
• Inserting
• Deleting
• Searching
• Sorting
• Merging
Some Quick MCQs
1. Which of these best describes an array?

a) A data structure that shows a hierarchical


behavior

b) Container of objects of similar types

c) Arrays are immutable once initialized

d) Array is not a data structure


1. Which of these best describes an array?

a) A data structure that shows a hierarchical


behavior

b) Container of objects of similar types

c) Arrays are immutable once initialized

d) Array is not a data structure

Explanation: Array contains elements only of the same type.


2. How do you initialize an array in C?
a) int arr[3] = (1,2,3);

b) int arr(3) = {1,2,3};

c) int arr[3] = {1,2,3};

d) int arr(3) = (1,2,3);


2. How do you initialize an array in C?
a) int arr[3] = (1,2,3);

b) int arr(3) = {1,2,3};

c) int arr[3] = {1,2,3};

d) int arr(3) = (1,2,3);

Explanation: This is the syntax to initialize an array in C.


3. In general, the index of the first element in an
array is __________
a) 0

b) -1

c) 2

d) 1
3. In general, the index of the first element in an
array is __________
a) 0

b) -1

c) 2

d) 1

Explanation: In general, Array Indexing starts from 0. Thus, the index


of the first element in an array is 0.
4. A mathematical-model with a collection of
operations defined on that model is called
a) Data Structure

b) Abstract Data Type

c) Primitive Data Type

d) Algorithm
4. A mathematical-model with a collection of
operations defined on that model is called

a) Data Structure

b) Abstract Data Type

c) Primitive Data Type

d) Algorithm

You might also like