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

Data Structures

Uploaded by

Jere Mih
Copyright
© © All Rights Reserved
0% found this document useful (0 votes)
23 views

Data Structures

Uploaded by

Jere Mih
Copyright
© © All Rights Reserved
You are on page 1/ 1

Data Structure is a systematic way to organize data in order to

use it efficiently. Xticx of data Structure Correctness − Data


structure implementation should implement its interface correctly.
Time Complexity − Running time or the execution time of
operations of data structure must be as small as possible. Space
Complexity − Memory usage of a data structure operation should
be as little as possible .Worst Case - This is the scenario where a
particular data structure operation takes maximum time it can take.
Average Case - This is the scenario depicting the average
execution time of an operation of a data structure. If an operation
takes ƒ(n) time in execution, then m operations will take mƒ(n)
time. Best Case - This is the scenario depicting the least possible
execution time of an operation of a data structure. Data − Data are
values or set of values. Data Item − Data item refers to single
unit of values. Group Items − Data items that are divided into sub
items are called as Group Items. Elementary Items − Data items
that cannot be divided are called as Elementary Items. Attribute
and Entity − An entity is that which contains certain attributes or
properties, which may be assigned values. Entity Set − Entities of
similar attributes form an entity set. Field − Field is a single
elementary unit of information representing an attribute of an
entity. Record − Record is a collection of field values of a given
entity. File − File is a collection of records of the entities in a
given entity set. Arrays An array is a number of data items of the
same type arranged contiguously in memory. Deletion Operation
Deletion refers to removing an existing element from the array and
re-organizing all elements of an array. Queue is an abstract data
structure, somewhat similar to Stacks. Unlike stacks, a queue is
open at both its ends. Traverse − print all the array elements one
by one. Insertion − Adds an element at the given index. Deletion
− Deletes an element at the given index. Search − Searches an
element using the given index or by the value. Update − Updates
an element at the given index. -Best Case ScenarioIn the best
scenario, all our nodes are evenly distributed throughout out tree.
No one path is longer than any other. This is called a balanced tree
and it gives us the best possible runtime for the operations
performed on it. every time you choose a branch to go down, you
are essentially diving the number of nodes you must search
through in half. The height for a balanced binary tree will be Log
N therefore time complexity for its basic operations will be O(log
n)S-Worst Case Scenario (3 Marks)In the worst case ,each time
we add a leaf, it is added to the same path. This would occur if a
sequence of increasing numbers was added to the tree because
each number is bigger than the last it will always take the right
path this causes the tree to have a height of N .this tree would have
the time complexity of O(N)Draw a binary Tree for the
expression : A * B - (C + D) * (P / Q)

Briefl
y explain how you can declare an array, initialize and access the
values in that particular array. An example will be very helpful.
Declare Here's how you can declare an array in
Java:Datatype[] arrayname;Double[] data;Here data is an
array that can hold values of type doubleInitializeHere's how
you can initialize an array during declaration.Int[ ] age = {12,
4, 5, 2, 5};This statement creates an array and initializes it
during declaration.The length of the array is determined by
the number of values provided which is separated by
commas. In our example, the length of age array is
5.AccessYou can easily access and alter array elements by
using its numeric index. .class ArrayExample { public static
void main(String[] args) {int[] age = new int[5]; // insert 14 to
third element age[2] = 14; // insert 34 to first element..age [0]
= 34;for (int i = 0; i < 5; ++i) { System.out.println("Element at
index " + i +": " + age[i]); } }}When you run the program,
the output will be:Element at index 0: 34Element at index
1: 0Element at index 2: 14Element at index 3: 0Element at
index 4: 0Sort the following list of elements using insertion
sort.23 78 45 8 32…23 45 78 8 32…8 23 45 78 32...8 23 32
45 78...8 23 32 45 78

You might also like