0% found this document useful (0 votes)
4 views

Datastructue and Software Eng

The document discusses various data structures, including arrays, linked lists, stacks, queues, and trees, highlighting their characteristics, advantages, and disadvantages. It also covers software concepts such as software processes, the Software Development Life Cycle (SDLC), and different SDLC models. Key points include the limitations of arrays compared to linked lists, the operations associated with stacks and queues, and the stages involved in software development.

Uploaded by

Shar Ayu
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Datastructue and Software Eng

The document discusses various data structures, including arrays, linked lists, stacks, queues, and trees, highlighting their characteristics, advantages, and disadvantages. It also covers software concepts such as software processes, the Software Development Life Cycle (SDLC), and different SDLC models. Key points include the limitations of arrays compared to linked lists, the operations associated with stacks and queues, and the stages involved in software development.

Uploaded by

Shar Ayu
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Array in Data Structure

Each element in an array is of the same data type and carries the same size that is
4 bytes.

Elements in the array are stored at contiguous memory locations

A very important limitation of primitive data types is the fact that values cannot
be stored in contiguous memory locations. This problem is solved by using arrays,
in which the Java array occupies dynamic memory in which individual elements are
stored in contiguous locations, one after the other.

Disadvantages
it is impossible to declare array withoud knowning the size of array.

the size of array in java cannot be increase or decreased.

they can only stores the data of same kind .


---------------------------------------
for-each loop in array imp

class Testarray1{
public static void main(String args[]){
int arr[]={33,3,4,5};
//printing array using for-each loop
for(int i:arr)
System.out.println(i);
}}

Declare Array:-
int a[]=new int[5];

triverse in array
class triverse{
public static void main(String args[]){
int arr[5]={18,30,15 ,70,12};
int i;
for(i=0, i<5; i++){
System.out.println(arr[i]);
}
}
}

insert element in array


import java.util.*;
class insert{
public static void main(String args[]){
int arr[5]={10,49,3,4,5};
int i,pos,n(length of array)=5,x;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the element")
x=sc.nextInt();
System.out.println("Enter position of element");
pos=sc.nextInt();

for(i=(n-1); i>=(pos-1); i--){


a[i+1]=a[i];
}

a[pos-1]=x;
System.out.println("After inserting");
for(int i=0; i<n; i++){
Sytem.out.print(a[i])
}

}
}
------------------------------------------------------------
n=(size of array)

for(int i=0; i<n; i++){


if(a[i]==x)
{
flag=1;
loc=i;
break;
}
else
{
flag=0;
}

if(flag==1)
{
for(int i=loc+1; i<n; i++){
a[i-1]=a[i];
}

System.out.print("After deleting")
for(int i=0; i<n-2; i++)
{
Sytstm.out.println(a[i])
}
else{
System.out.println("Element not found");
}
}
}
------------------------------------------------------------
We read the linear data structures like an array, linked list, stack and queue in
which all the elements are arranged in a sequential manner.
------------------------------------------------------------
DS Linked List
Linked list is a linear data structure that includes a series of connected nodes.
Why use linked list over array?
1.The size of the array must be known in advance before using it in the program.
2. It is almost impossible to expand the size of the array at run time.
3.All the elements in the array need to be contiguously stored in the memory.
Inserting an element in the array needs shifting of all its predecessors.

Linked list is useful because -


It allocates the memory dynamically. All the nodes of the linked list are non-
contiguously stored in the memory and linked together with the help of pointers.
struct node
{
int data;
struct node *next;
}

Singly-linked list
Doubly linked list
Circular singly link list
Circular doubly linked lis

Singly-linked list -A node in the singly linked list consists of two parts: data
part and link part. Data part of the node stores actual information that is to be
represented by the node, while the link part of the node stores the address of its
immediate successor.

Doubly linked list - in which a node contains a pointer to the previous as well as
the next node in the sequence.

Circular singly linked list - In a circular singly linked list, the last node of
the list contains a pointer to the first node of the list.

Circular doubly linked list - in which a node contains pointers to its previous
node as well as the next node. Circular doubly linked list doesn't contain NULL in
any of the nodes. The last node of the list contains the address of the first node
of the list. The first node of the list also contains the address of the last node
in its previous pointer.

Applications:-
1.dynamic memory alocation;
2.memory alocation done at run time
3.The various operations like student's details, employee's details, or product
details can be implemented using the linked list as the linked list uses the
structure data type that can hold different data types.

------------------------------------------------------------
DS Stack
A Stack is a linear data structure that follows the LIFO (Last-In-First-Out)
principle.

a stack can be defined as a container in which insertion and deletion can be done
from the one end known as the top of the stack.

A Stack is an abstract data type with a pre-defined capacity, which means that it
can store the elements of a limited size.

It is a data structure that follows some order to insert and delete the elements,
and that order can be LIFO or FILO.

Common operations
push(),pop(),isEmpty(),isFull(),peek(),count(),change(),display()

Application:
UNDO/REDO,DFS,Backtracking,
Expression Conversion(infix to prefix,infix to postfix)
memory management(all the variables are assigned to a function call stack
memory.when the fun completed its execution, all the variables assigned in the
stack are released).
------------------------------------------------------------
DS Queue
A queue can be defined as an ordered list which enables insert operations to be
performed at one end called REAR and delete operations to be performed at another
end called FRONT.Queue is referred to be as First In First Out list.

Applications of Queue
queue are widely used as waiting lists for a single shared resource like printer,
disk ,CPU;
queue are used as buffers in most of the applications like MP3 media player,CD
player etc maintain the play list in media players in order to add and remove the
songs from the play list
Queue are used in operating system for handling interrupts
------------------------------------------------------------
Some factors are considered for choosing the data structure:
What type of data needs to be stored?:
Cost of operations:
Memory usage:
------------------------------------------------------------
Tree data structure
A tree data structure is a non-linear data structure because it does not store in a
sequential manner. It is a hierarchical structure as elements in a Tree are
arranged in multiple levels.

In the Tree data structure, the topmost node is known as a root node. Each node
contains some data, and data can be of any type.

Each node contains some data and the link or reference of other nodes that can be
called children.

Applications of trees
Storing naturally hierarchical data:
Organize data:
Routing table:

types
1.Binary tree: each node in a tree can have utmost two child nodes
2.Binary Search tree:in which one node is connected to n number of nodes. It is a
node-based data structure.
Varients of binary search tree:
1.AVL tree:It is a self-balancing binary search tree
2.Splay tree: recently accessed element is placed at the root position of tree by
performing some rotation operations.
------------------------------------------------------------
Software Eng
------------------------------------------------------------
Software :-The term software specifies to the set of computer programs, procedures
and associated documents (Flowcharts, manuals, etc.) that describe the program and
how they are to be used.

Software Processes:-A software process is the set of activities and associated


outcome that produce a software product.

Some common activities:-


Software specifications:
Software development:
Software validation:
Software evolution:
program is a subset of software.

three components of software


programs
documentation
operation procedures
------------------------------------------------------------
Software Development Life Cycle (SDLC)
A software life cycle model (also termed process model) is a pictorial and
diagrammatic representation of the software life cycle. A life cycle model
represents all the methods required to make a software product transit through its
life cycle stages.

1.planning and requirement analysis


2.Defining
3.Designing
4.coding
5.Testing
6.Deployment
7.Maintenance

Requirement techniques:-Hold One-on-One Interviews,Utilize Use Cases,Build


Prototypes

types of requirements:-
Functional Requirements
Technical Requirements
Transitional Requirements
Operational Requirements
------------------------------------------------------------
SDLC MODELS
Waterfall model
prototype model
RAD Model
spiral model
Agile model
iterative model

1.Water fall model:-when the requirements are constant and not changed regularly.A
project is short.The situation is calm.tool and technology used is consistent and
is not changing.

2.Reduce the risk,where requirement are changing/uncommitted,reduce maintenance


cost,error can be detected earlier,disadvantages:-difficult to know how long the
project will last.prototyping tools are expensive.

3.Rapid Application Development:-protopyping and feedback.


flexible,reduced development,increases reusability of features,Dis:-required highly
skilled designers,smaller proj we cannot use red,high technical risk,user
involvement.

You might also like