...#include<stdio.h> #include<conio.h> #include<alloc.h> struct node { int x; struct node *next; } ; struct node *head, *curr, *tail, *delte, *insert, *temp; void input() { printf("Press '0' to Exit Input\n\n"); curr=(struct node*)malloc(sizeof(node)); printf("Enter an Integer: "); scanf("%d", &curr->x); while(curr->x!=0) { if(head==NULL) { head=curr; head->next=NULL; tail=curr; } else { tail->next=curr; tail=curr; curr->next=NULL; } curr=(struct node*)malloc(sizeof(node)); printf("Enter an Integer: "); scanf("%d", &curr->x); } } void sort() { int no_ex; int x; curr=head; do { no_ex=0; curr=head; while(curr->next!=NULL) { if(curr->x>curr->next->x) { x=curr->x; curr->x=curr->next->x; curr->next->x=x; no_ex=1; } curr=curr->next; } } while(no_ex); } void insrt() { int test=0; printf("\nWhat to Insert?: "); insert=(struct node*)malloc(sizeof(node)); scanf("%d", &insert->x); curr=head; if(head->x>insert->x) { insert->next=head; head=insert; } else { while(curr->next!=NULL) { if(curr->next->x>insert->x&&test!=1) { insert->next=curr->next; ...
Words: 496 - Pages: 2
...#include #include struct node { int info; struct node *link; }; struct node *start=NULL,*n,*temp,*temp1; void create(); void display(); void insbeg(); void inspos(); void delbeg(); void delend(); void search(); int main() { int i; printf("------linked list----------\n"); n=(struct node *)malloc(sizeof(struct node)); printf("enter the element:--->"); scanf("%d",&n->info); n->link=NULL; start=n; for(i=0;iinfo); n->link=start; start=n; } void create() { n=(struct node *)malloc(sizeof(struct node)); printf("enter the element--->"); scanf("%d",&n->info); temp=start; while(temp->link!=NULL) { temp=temp->link; } temp->link=n; n->link=NULL; } void display() { printf("The list is:\n"); temp=start; while(temp!=NULL) { printf("%d\n",temp->info); temp=temp->link; } } void inspos() { int pos, count=0; temp=start; if(temp==NULL) count=0; else count=1; printf("enter position."); scanf("%d",&pos); if(pos==1) { insbeg(); return; } n=(struct node *)malloc(sizeof(struct node)); printf("enter the element--->"); scanf("%d",&n->info); while(temp->link!=NULL) { if(count==pos-1) break; temp=temp->link; count++; } n->link=temp->link; temp->link=n; } void delbeg() { temp=start; start=start->link; free(temp); } void delend() { temp=start; while(temp->link...
Words: 251 - Pages: 2
...LINKEDIN A social networking site is a platform to build social relations among people who, for example share interests, activities, backgrounds or real-life connections. LinkedIn is a social networking site designed specifically for people in professional occupations. The goal of the site is to allow registered members to establish and document networks of people they know and trust professionally. Founded in December 2002 and launched on May 5, 2013, it is mainly used for professional networking. In 2006, LinkedIn increased to 20 million viewers. As of June 2013, LinkedIn reports more than 259 million acquired users in more than 200 countries and territories. The site is available in 20 languages. A LinkedIn member’s profile page, which emphasizes employment history and education, has professional network news feeds and a limited number of customizable modules. Basic membership for LinkedIn is free. Network members are called “connections.” Unlike other free social networking sites like Facebook or Twitter, LinkedIn requires connections to have a pre-existing relationship. With basic membership, a member can only establish connections with someone he has worked with, knows professionally or has gone to school with. Connections up to three degrees away are seen as part of the member's network, but the member is not allowed to contact them through LinkedIn without an introduction. Premium subscriptions can...
Words: 1164 - Pages: 5
...Linked List 1 List vs Arrays Two built-in data structures that can be used to organize data, or to create other data structures: • Lists • Arrays Lists A list is an ordered set of data. It is often used to store objects that are to be processed sequentially. Arrays An array is an indexed set of variables, such as dancer[1], dancer[2], dancer[3],… It is like a set of boxes that hold things. A list is a set of items. An array is a set of variables that each store an item. Arrays and Lists You can see the difference between arrays and lists when you delete items. Arrays and Lists In a list, the missing spot is filled in when something is deleted. Arrays and Lists In an array, an empty variable is left behind when something is deleted. What’s wrong with Array and Why lists? • Disadvantages of arrays as storage data structures: – slow searching in unordered array – slow insertion in ordered array – Fixed size • Linked lists solve some of these problems • Linked lists are general purpose storage data structures and are versatile. Linked Lists A Head B C • A linked list is a series of connected nodes • Each node contains at least – A piece of data (any type) – Pointer to the next node in the list • Head: pointer to the first node • The last node points to NULL node A data pointer The composition of a Linked List • A linked list is called "linked" because each node in the series has a pointer that points...
Words: 2375 - Pages: 10
...the data items in the memory are not allocated contiguously i.e. the data items are dispersed in the memory. The first data item will have a link to the second data item and second data item will have a link to the third data item and so on. Pros • Uses memory efficiently that the free contiguous memory in not an requirement for allocating data items • The length of the data items is not necessary to be known prior to allocation Cons • Overhead of the link to the next data item Linked list: linked list a data structure which stores data in the form of nodes.It does not require linear memory as arrays. Each node contains a data part and a pointer part(a pointer to the next data in the list) link or node is object of a class.there are so many types of linked list 1) single linked list 2)doubly linked list 3)circular linked list. single linked list: here links contains pointer to first data and last data in the list.As said earlier a pointer to the next data. example of a linked list: class node{// all nodes will be the objects of this class public int data; public link next_node;//a pointer to next data } public node(int data){ this.data=data; }//end of constructor public void showdata(){ System.out.println("data= "+data); } }//end of class node After defining class for each node we need to define a class for link list. Link list contains a pointer to the first node in the list,Which should be initialized to null in the beginning. All the operations...
Words: 475 - Pages: 2
...file pair. The main program is the driver of the whole exercise and uses (includes) all of the .h files of the different linked lists. The main program performs the following steps: 1. It begins by generating N (see below) random integers between 0 and 9 and stores them in a binary file called insert.bin. It should let the user know what numbers were generated and written. 2. It then generates another N random integers between 0 and 9 and stores them in another binary file called delete.bin. It should let the user know what numbers were generated and written. 3. It reads insert.bin one integer at a time and stores the value read into each one of the lists, keeping each list sorted in increasing order. If a number occurs more than once in the list, instead of creating a new node, it increments a count variable on the node. It should let the user know what value it read from the file and it should show the four lists with the new value inserted, identifying each type of list. To display a node, show key and count. 4. Once done reading the insert.bin file, it starts reading the delete.bin file one value at a time, deleting that value from each of the linked lists. If the value occurs in the list more than once (the count member on the node is greater than 1), it decrements the count. It is only when the count is 1 and deleting the node would make it 0 that the node is actually removed from the list and freed. It should let the user know what value it read from the file and...
Words: 290 - Pages: 2
...Near the end of each unit a corresponding homework assignment will be given. De pending on how quickly we finish material, we may end up spending more or less time on each topic. Readings are highly recommended but are not directly evaluated; for example, there are no in-class quizzes about readings. Unit 1 Topics Course Overview C++ Programming Language Basics Functions; Strings; Input/Output Streams Collections, Containers Abstract Data Types (ADTs) Stack/Queue, Vector, Grid, Map, Set, Lexicon Designing Classes Recursion Recursive Algorithms and Data Fractals Recursive Exhaustive Search Backtracking Sorting Algorithm Efficiency; Big-Oh Notation Arrays and Pointers Dynamic Memory Allocation Implementing Collection Classes Hashing Linked Lists Linked Data Structures Binary Trees; Binary Search Trees (BSTs) Graphs Advanced Topics Readings Chapters 1-4 Assignments HW1: Life 2 Chapters 5-6 HW2: Word Ladders, Random Writer 3 Chapters 7-8 HW3: Recursion 4 Chapters 9-10 HW4: Boggle 5 Chapters 11-12, 14 HW5: Priority Queue 6 Chapters 12, 14, 16 HW6: Huffman Encoding 7 Chapters 18-20 HW7: Trailblazer Please note that this is a preliminary rough schedule and is subject to change without advance notice. Refer to the course web site for the most up-to-date information about what topics will be covered, appropriate reading, and assignments. This document is copyright © Marty Stepp, licensed under Creative Commons Attribution 2.5 License...
Words: 268 - Pages: 2
...A linked list is made up of a series of objects, called the nodes of the list. Because a list node is a distinct object. Linked lists are among the simplest and most common data structures. The principal benefit of a linked list over a conventional array is that the list elements can easily be inserted or removed without reallocation or reorganization of the entire structure because the data items need not be stored contiguously in memory or on disk, while an array has to be declared in the source code, before compiling and running the program. Linked lists allow insertion and removal of nodes at any point in the list, and can do so with a constant number of operations if the link previous to the link being added or removed is maintained during list traversal. Singly Linked List: Singly linked lists contain nodes which have a data field as well as a next field, which points to the next node in line of nodes. Operations that can be performed on singly linked lists include insertion, deletion and traversal. Finding and Deleting Specified Link: Finding algorithm Beginning from the head, 1. Check, if the end of a list hasn't been reached yet; 2. Do some actions with the current node, which is specific for particular algorithm; 3. Current node becomes previous and next node becomes current. Deleting 4. Save reference to link 5. Delete it, save first to old next 6. Return deleted link Operation on Singly Link List: * Search * Insert ...
Words: 818 - Pages: 4
...MinEmail: SMS Alert System for Managing Critical Emails Authors: Kyle Rector and Joshua Hailpern Reviewer: Khawaja Ahmed Ali 1. What is the purpose of the work? Most of the people rely on email as their primary mode of business communication. However, as number of emails increase, it become difficult to manage them. This may leads to the poor attention to some important emails. Missing an important email may cause delay in project progress and frustration in users. There are numbers of manual and automatic procedures to filter emails based on various features. These methods identify the important emails and highlight them in some way. However, all of the methods have some limitations and thus, an end user cannot get full benefits. In this paper, authors presented an alert system for emails. MinEmail uses SMS as a notification tool about important emails. It sends an SMS to notify and remind a user about any critical email. This systems automatically predict and label important emails. Authors developed models to predict how and when emails should be addressed. The primary contribution is not to develop a novel system to combine two different communication methods: Email and SMS, but to propose models for prediction and labeling of critical emails. 2. How do the authors achieve this purpose? Why is the particular approach adopted? Related research shows the three ways of addressing the above mentioned problem: a. Manual Email Management b. Automatic...
Words: 811 - Pages: 4
...IT 265 Data Structures for Problem Solving Data Structures and Methods 9/20/2014 Phase 5 Contents Executive Summary 4 Phase 1 4 Phase 2 4 Phase 3 4 Phase 4 4 Phase 5 5 Section 1: Lists, Stacks, and Queues 6 Stacks 6 Queues 10 Section 2: Hashing, Heaps and Trees 14 Section 3: Sorting Algorithms 20 Insertion sort 20 Bubble Sort 20 Selection sort 21 Section 4: Searching 22 Array 22 Linked Lists 23 Section 5: Recursion 30 References 33 Executive Summary Phase 1 A list is a collection of items in which the items have a position (Weiss, 2010). A linked list allows data to be input or removed easily because each of the data items in the list is connected to its neighbor by a pointer that can be quickly and easily modified to accommodate new or removed items (CTU M.U.S.E. 2014). The Phase 1 portion of this document will be demonstrating the implementation of Stacks and Queues. Phase 2 Hash tables can be viewed as an array of lists and are used to speed up a search for data by creating a situation that does not require the search to start at the beginning and go through every item. The identifying value is the key and the associated record is the data, thus a hash table is a collection of (key, value) pairs. Phase 3 In order to efficiently use a database, the data must be stored in some sort of order. There are a number of different sorting algorithms; a programmer would choose which one to use depending on the amount...
Words: 3704 - Pages: 15
...STRUCTURES, POINTERS, AND LINKED DATA STRUCTURES • The following slides provide the C-code around which we will structure our discussion tomorrow. • Please note that this code by itself is incomplete. • Class attendance is necessary to understand the theme. • Those who do not attend the class must read the Text book and come to consultations, if help is needed. Structures and Lists #include #include struct Student { char *name ; int age; }; // Note: char *name ="xxxxxxxxxxxxxx"; is // not permitted in structures. Why? int main(void){ struct Student s; // allocates memory. s.name = malloc(20*sizeof(char)); scanf("%s",s.name); s.age = 20; printf("1:%s %d\n",s.name, s.age); struct Student *ps; ps = &s; // Dot has higher priority over & scanf("%s%d",(*ps).name,&(*ps).age); printf("2:%s %d\n", (*ps).name, (*ps).age); printf("3:%s %d\n",ps->name,ps->age+3); struct Student *ps1; // allocate memory by malloc() dynamically. ps1 = malloc(sizeof(struct Student)); ps1->name = malloc(20*sizeof(char)); scanf("%s%d",ps1->name,&(ps1->age)); printf("4:%s %d\n",ps1->name,ps1->age+3); printf("5:%s %d\n", (*ps1).name, (*ps1).age); } Student s 0028FF08 malloc 003C1110 name name age age ps malloc 0028FF00 003C1188 ps1 malloc #include #include struct S1 { int a1; char b1; }; struct S2{ int a2; char b2; struct S1 *p2; }; struct S3{ int a3; char b3; struct S1 *p3a; struct S2 *p3b; }; Linked structures // Self...
Words: 1984 - Pages: 8
...COSC5315 Group Project due: November 25/26, 2014 Exploration of Grammar/Acceptor/Language Applications Task: This is a group project for which up to four people can work together. Your task is to write a report of no more than seven pages on application of Grammars or Acceptors or Languages of any type or types, 0, 1, 2, or 3. One such application is a design of a CFG for an abbreviated version of java illustrated by the following java program. Your report must be well organized with some suitable headings such as introduction that includes (a) your own preference/reason for choosing a particular application when others are also available, (b) anticipated results or findings and (c) how work/labor is divided among group members in case of a group work, (d) the main body that clearly shows a detailed process of realizing a particular practical application, and (e) conclusion that includes what you think you really have learned, if any, and what you think is the contributions/benefits of the application you explored. //** import java.util.*; public class BinarySearchTree //visibility modifier can be also private { public class TreeNode // an inner class of class BinarySearchTree, for binary trees { // 3 private instance variables //////////////////////////////////////////////////////// private int data; // visibility modifier can be also public or protected and // type can be also float, double, char, short, long or boolean private TreeNode leftLink; ...
Words: 543 - Pages: 3
...DS PROJECT ID: k12-2059 NAME: Sufyan Shahid SUBTREE MINER SUBTREE MINER: This project is about mining of frequent subtree in a parent tree. This type of algorithms are used in web mining, data mining and network mining. For Example: In Google when we search anything and imagine if all the data in Google data base is saved as tree, so, when we search, it gives all the subtree, its relative patterns and output it. In this program, there is a parent tree and input subtree, this program will search whether the input is in the parent tree and number of occurrence of subtree in parent tree. Let, 5,3,4,5,3,4,5,3,4,5,3,4,5,3,4 5,3,4 Are the elements of binary tree in level order are the elements of Binary tree in level order 5 5 3 4 3 4 5 4 3 5 3 4 5 4 3 5 3 4 ...
Words: 301 - Pages: 2
...Data Structures & Algorithms Coursework Assignment 1 Q1. (a) Algorithm swap(x, y): Node n head While (n.getNext () != x ) do n n.getNext() Node v y.getNext () n.setNext(y) y.setNext(x) x.setNext(v) (b) Algorithm swap Doubly(x, y): DNode n x.getPrev() DNode v y.getPrev() n.setNext(y) y.setPrev(n) y.setNext(x) x.setPrev(y) x.setNext(v) v.setPrev(x) (c) The run time complexity for the singled linked algorithm is O (n) and for the doubly linked algorithm is O (1). Doubly linked list has the best time complexity. Time complexity in singly linked list take more time because we have to move from head to the node before x Q2. (b) RedBlueStack implements Stack{ protected Object A[]; Int capacity; int top = -1; RedBlueStack(int cap) { A = new Object [capacity]; capacity = cap; } int size() { return (top + 1); } void push(Object obj) throws FullStackException { if (size() == capacity) throws new FullStackException("Stack is full."); A[++top] = obj; } Object top() throws EmptyStackException { if (isEmpty()) throws new EmptyStackException("Stack is empty."); return A[top]; } Boolean isEmpty() { return (top < 0); } Object top() throws EmptyStackException { if (isEmpty()) throws new EmptyStackException("Stack is empty."); return A[top]; } Object pop() throws EmptyStackException { Object elem; if (isEmpty()) throws new EmptyStackException("Stack...
Words: 551 - Pages: 3
...each operation. Don't write any code. Assume as if you are using push and pop member functions of the stack. AB-CD+E*+ (where A=5, B=3, C=5, D =4, and E=2) Question 5 Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation : 50,40,+,18, 14,-, *,+ Question 6 Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation : TRUE, FALSE, TRUE, FALSE, NOT, OR, TRUE, OR, OR, AND Question 7 Write a program for creating polynomial using linked list? Question 8 Each node of a STACK contains the following information, in addition to required pointer field : i) Roll number of the student ii) Age of the student Give the structure of node for the linked stack in question TOP is a pointer which points to the topmost node of the STACK. Write the following functions. i) PUSH() - To push a node to the stack which is allocated dynamically ii) POP() - To remove a node from the stack and release the memory. Question 9 Write a function in C to perform a DELETE operation in a dynamically allocated link list considering the following description : struct Node {...
Words: 357 - Pages: 2