19

Click here to load reader

Assignment 2

Embed Size (px)

Citation preview

Page 1: Assignment 2

SHANNITISHBHIMDEVINAARSHAD (didn’t gave notes + not presenting)

ASSIGNMENTPRESENTED BY:

Page 2: Assignment 2

PRESENTING ON:ALGORITHMS TO INSERT AND

DELETE DATA INTO/FROM:-STACKS-QUEUES

LINKED LISTS:-INITIALISATION

-INSERTION OF DATA-DELETION

-SEARCHING OF DATA ELEMENTS

Page 3: Assignment 2

STACKS

A stack is a container of abstract data or structure data that are inserted and removed according to the principle of LAST IN FIRST OUT (LIFO). The object can be inserted at any time but only the last object can be removed. It is mainly based on the push and pop operation.

PUSH OPERATION: It add data to the top of the list, hiding any

item already on the stack.POP OPERATION: It removes an item from the top of the lists.

Page 4: Assignment 2

EXAMPLE OF PUSH AND POP:

Page 5: Assignment 2

QUEUESA Queue differ from a stack. A queue is a

particular kind of collection in which the entities are kept in order and principle of FIRST IN FIRST OUT (FIFO) data structure.

FIFO: In FIFO the first element added to a queue will

be the first one to be removed. ENQUEUE: It is element that are inserted at the rear.DEQUEUE: It is element that are removed at the front.

Page 6: Assignment 2

EXAMPLE OF ENQUEUE AND DEQUEUE:

Page 7: Assignment 2

LINKED LISTS In computer science, a linked list is a data structure

that consists of a sequence of data records such that in each record there is a field that contains a reference (i.e., a link) to the next record in the sequence.

Linked lists and arrays are similar since they both store collections of data. The terminology is that arrays and linked lists store "elements" on behalf of "client" code. The specific type of element is not important since essentially the same structure works to store elements of any type. One way to think about linked lists is to look at how arrays work and think about alternate approaches.

Page 8: Assignment 2

INITIALISATION(To assign a value to a variable or storage location in a computer program)Initialization in computing is the setting (or

“formatting”) of a variable to some initial value, either by statically embedding the value at compile time, or else by assignment at run time. A section of code that performs such initialization is generally known as “initialization code” and may include other, one-time-only, functions such as opening files. Setting a memory location to hexadecimal zeroes is also sometimes known as “clearing” and is often performed by an exclusive or instruction (both operands specifying the same variable), at machine code level, since it requires no additional memory access.

Page 9: Assignment 2

INITIALISATION (CONTD.)Certain linked list operations (init, insert,

etc.) may change element at start of list (what ListStart points at)to change what ListStart points to could pass a

pointer to ListStart (pointer to pointer)alternately, in each such routine, always return

a pointer to ListStart and set ListStart to the result of function call (if ListStart doesn’t change it doesn’t hurt)

EPtr initList() { return NULL;}

ListStart = initList();

Page 10: Assignment 2

FIRST EXAMPLES OF INITIALISATION:

Page 11: Assignment 2

SECOND EXAMPLE OF INITIALISATION

Page 12: Assignment 2

INSERTION OF DATA:It is a methods followed in arranging a set of data items into a sequence according to precise rules.

A formula used to record data into anew sequence. Like all complicated problems, there are many solution that can achieve the same result, and one sort algorithm can re sequence data faster than another.

Page 13: Assignment 2

EXAMPLES OF INSERTION OF DATA:

Page 14: Assignment 2

DELETIONDeletion is act of deleting or removing by

striking out material such as a word or passage that has been removed from a written body.

TYPES OF DELETION:1. SPEEDY DELETION2.PROPOSED DELETION

Page 15: Assignment 2

SPEEDY DELETIONThis is meant to be used in uncontroversial cases. The main reason articles are speedily delete are for being extremely short on material or context.

Page 16: Assignment 2

PROPOSED DELETIONThis type of deletion is used to delete an article in seven days if no one objects. Proposed deletion should only be used for uncontroversial deletion nomination, it should not be used as a way of getting an article deleted.

Page 17: Assignment 2

EXAMPLES OF DELETIONto delete

Need to change pointer of record before the one being deleted

delete operation:

But what if NO element before the one to be deleted?

ListStart

5 9 86

ListStart

5 9 86

to deleteListStart

5 9 86

delete operation:

ListStart

5 9 86

Page 18: Assignment 2

SEARCHING OF DATA ELEMENTSIn computer, a search algorithm, broadly speaking, is an algorithm for finding an item with specified properties among a collection of item. The items may be stored individually as a record in a database or may be elements of a search space defined by a mathematical formula or procedure.

Page 19: Assignment 2

THANK YOU FOR YOUR ATTENTION