answersLogoWhite

0


Best Answer

Encoder:- In character recognition, that class of printer which is usually designed for the specific purpose of printing a particular type font in predetermined positions on certain size forms.

(electronics) In an electronic computer, a network or system in which only one input is excited at a time and each input produces a combination of outputs. encoder http://www.answers.com/main/Record2?a=NR&url=http%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FImage%3AEncoder%2520diagram.svg http://www.answers.com/main/Record2?a=NR&url=http%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FImage%3AEncoder%2520diagram.svg Circuit diagram of a single bit 4-to-2 line encoder A3A2 A1 A0 F1 F0 0 0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 1 0 Encoder:- In character recognition, that class of printer which is usually designed for the specific purpose of printing a particular type font in predetermined positions on certain size forms.

(electronics) In an electronic computer, a network or system in which only one input is excited at a time and each input produces a combination of outputs. encoder http://www.answers.com/main/Record2?a=NR&url=http%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FImage%3AEncoder%2520diagram.svg http://www.answers.com/main/Record2?a=NR&url=http%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FImage%3AEncoder%2520diagram.svg Circuit diagram of a single bit 4-to-2 line encoder A3A2 A1 A0 F1 F0 0 0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 0 1 1 Truth table

User Avatar

Wiki User

16y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

#include "stdio.h"

#include "alloc.h"

typedef struct dubll

{

int data;

struct dubll *leftlink,*rightlink;

}*DUBLL;

DUBLL high,temp_node,low,last,pntr;

int flag=0;

DUBLL NodeAlloc();

DUBLL Search(int,int);

void CreateItem();

void AppendItem();

void PrintItem();

void DeleteItem();

DUBLL Search(int item,int flag);

DUBLL NodeAlloc();

void InsertItem();

void main(void)

{

int choice,Item;

high=NULL;

while(1)

{

clrscr();

printf("\n \t\t\t***** M A I N M E N U *****\n\n");

printf("\n 1: Create Linked List \n 2: Append a Node to the List \n 3: Traverse the List \n 4: Delete a Node from the List \n 5: Search a Node \n 6: Insert a Node to the List \n 7: Close \n\n\t\t Enter your Option [ ]\b\b");

scanf("%d",&choice);

switch(choice)

{

case 1:

CreateItem();

puts("\nPress any key to go back to main menu.");

getch();

break;

case 2:

AppendItem();

break;

case 3:

PrintItem();

puts("\nPress any key to go back to main menu.");

getch();

break;

case 4:

DeleteItem();

break;

case 5:

printf("Find an Item: ");

scanf("%d",&Item);

temp_node=Search(Item,0);

if(temp_node)

{

puts("The item is available in the Linked List.");

}

else

{

puts("The item is not found in the Linked List.");

}

getch();

break;

case 6:

InsertItem();

break;

case 7:

exit();

default:

puts("Invalid choice.");

puts("\nPress any key to go back to main menu.");

getch();

break;

}

}

}

/* Function to Create the list*/

void CreateItem()

{

if(high==NULL)

{

printf("\n -Creating the list-");

temp_node=NodeAlloc();

printf("\n Enter starting data (as integer value) :");

scanf("%d",&temp_node->data);

high=temp_node;

}

else{ printf("\n List already created @ %d with %d as data.",high,high->data);}

}

/* Function to Append items to the list*/

void AppendItem()

{

low=high;

if(high==NULL)

{

CreateItem();

}

else

{

temp_node=NodeAlloc();

printf("\n Enter Item (in integer) :");

scanf("%d",&temp_node->data);

temp_node->rightlink=NULL;

while(low->rightlink!=NULL)

low=low->rightlink;

low->rightlink=temp_node;

temp_node->leftlink=low;

last=low->rightlink;

}

}

/* Function to Traverse the list both ways and print the data*/

void PrintItem()

{

DUBLL temp_node;

if(high==NULL)

{

printf("\n List is not available. Please create a list first.");

getch();

CreateItem();

}

temp_node=high;

last=low->rightlink;

printf("\n-Printing The List In Forward direction-\n");

while(temp_node!=NULL) //In forward direction

{

printf("\t %d",temp_node->data);

temp_node = temp_node->rightlink;

}

printf("\n");

printf("\n-Printing The List In Backward direction-\n");

temp_node=high;

if(temp_node->rightlink==NULL){printf("%d",temp_node->data);return; }

while(last!=NULL) //In backward direction

{

printf("\t %d",last->data);

last = last->leftlink;

}

}

/* Function to Delete items of the list*/

void DeleteItem()

{

int value;

DUBLL temp_node;

if(high==NULL)

{

printf("\n List is not available. Please create a list first.");

getch();

CreateItem();

}

printf("\n Item to delete :");

scanf("%d",&value);

pntr=Search(value,1);

pntr->leftlink->rightlink=pntr->rightlink;

pntr->rightlink->leftlink=pntr->leftlink;

temp_node=pntr;

free(temp_node);

}

/* Function to Search an item from the list*/

DUBLL Search(int item,int flag)

{

temp_node = high;

if(high==NULL)

{

printf("\n List is not available. Please create a list first.");

getch();

CreateItem();

}

while(temp_node!=NULL)

{

if(temp_node->data==item )

{

if(flag==0)

{

return(1);

}

else

{

return(temp_node);

}

}

temp_node=temp_node->rightlink;

}

}

/* Function to Allocate nodes*/

DUBLL NodeAlloc()

{

DUBLL tmep_node;

tmep_node=malloc(sizeof(struct dubll));

if(tmep_node==NULL)

{

printf("\n No memory available. Node allocation cannot be done.");

}

tmep_node->rightlink=tmep_node->leftlink=NULL;

return(tmep_node);

}

/* Function to Insert items in the middle of the list*/

void InsertItem()

{

int node;

DUBLL temp_node;

if(high==NULL)

{

printf("\n List is not available. Please create a list first.");

getch();

CreateItem();

}

temp_node=NodeAlloc();

printf("Position At which node to be inserted: ___ & New Item Value: ___ ");

scanf("%d",&node);

scanf("%d",&temp_node->data);

pntr=Search(node,1);

if(pntr->rightlink==NULL){printf("\n The operation is not possible."); getch();return;}

temp_node->leftlink=pntr; //creating link to new node

temp_node->rightlink=pntr->rightlink;

pntr->rightlink->leftlink=temp_node;

pntr->rightlink=temp_node;

printf("\n Item has been Inserted.");

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include<stdio.h>

#include<conio.h>

#include<malloc.h>

#include<process.h>

struct node

{

int num;

struct node *next;

struct node *prev;

}; /* declaring a global node of type struct */

typedef struct node NODE; /* providing a type definition to the above created structure */

NODE *head=NULL; /* declaring some of the global variable that would be used throughout the program */

NODE *temp, *first, last;

int info;

void display();

void insert_at_end();

void insert_at_begin();

void insert_at_specifiedpos();

void main() /* starting the main method() */

{

int i;

clrscr();

printf("\nprogram for insertion in a doubly linked list :\n");

do

{

printf("\nEnter your choice :\n");

printf("\n1.Insert element at the end of the linkedlist :");

printf("\n2.Insert element at the begin of the linkedlist :");

printf("\n3.Insert at any specified position in the linkedlist :");

printf("\n4.Exit\n");

fflush(stdin);

scanf("\n%d",&i);

switch(i)

{

case 1:

insert_at_end();

display();

break;

case 2:

insert_at_begin();

display();

break;

case 3:

insert_at_specifiedpos();

display();

break;

case 4:

exit(0);

}

}while(i<=4);

getch();

}

void insert_at_end()

{

printf("\nEnter your element in the linked list :");

scanf("%d",&info);

temp=(NODE *)malloc(sizeof(NODE)); /* allocating memory for the node to be inserted */

temp->num=info;

temp->next=NULL;

temp->prev=NULL;

if(head==NULL) /* checking whether list is empty */

{

head=temp;

first=temp;

last=temp;

}

else

{

first=head;

while(first->next!=NULL)

{

first=first->next;

}

first->next=temp;

temp->prev=first;

temp->next=NULL;

last=temp;

}

}

void display()

{

first=head;

printf("\nStatus of the doubly linked list is as follows :\n");

while(first->next!=NULL) /* traversing the linked list */

{

printf("\n%d",first->num);

first=first->next;

}

}

void insert_at_begin()

{

printf("\nEnter the value which do you want to insert at begining\n");

scanf("\n%d",&info);

temp=(NODE *)malloc(sizeof(NODE));

temp->num=info;

temp->next=NULL;

temp->prev=NULL;

if(head==NULL)

{

head=temp;

last=temp;

}

else

{

temp->next=head;

head->prev=temp;

temp->prev=NULL;

head=temp;

}

}

void insert_at_specifiedpos()

{

NODE *second;

int node_num,info;

int i=1;

printf("\nEnter the nodenumber after which you want to insert new node\n");

scanf("%d",&node_num);

printf("\nEnter the value of new node\n");

scanf("\n%d",&info);

temp=(NODE *)malloc(sizeof(NODE));

temp->num=info;

temp->next=NULL;

temp->prev=NULL;

first=head;

while(i<node_num)

{

second=first;

first=first->next;

}

temp->next=first;

temp->prev=second;

first->prev=temp;

second->next=temp;

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include

#include

#include

int pop(int[], int&);

int push(int[], int&, int);

void display(int[], int);

const int size=20;

void main()

{

int stack[size], item, top=-1, res;

char ch='y';

clrscr();

while(ch=='y' ch=='Y')

{ cout<<"Enter Item for insertion: ";

cin>>item;

res=push(stack, top, item);

if (res==-1)

{ cout<<"\nOver flow\n ";

exit(1);

}

cout<<"\nThe stack now is:\n";

display(stack, top);

cout <<"\n Insert more Y N : ";

cin >> ch;

}

cout << "\n\n------------------"

<< "\nDeletion of element begins... \n";

ch='y';

while (ch=='y'ch=='Y')

{

res=pop(stack, top);

if(res==-1)

{ cout<< "Under flow";

exit(1);

}

else

{ cout<<"\nElement deleted is : "<

cout<<"\n\nThe stack now is :";

display(stack, top);

}

cout<<"\nWant to delete more element ";

cin >> ch;

}

}

int push(int stack[],int& top, int ele)

{ if (top==size-1)

return -1;

else

{ top ++;

stack[top]=ele;

}

return 0;

}

int pop (int stack[], int &top)

{ int ret;

if(top==-1)

return -1;

else

{ ret = stack[top];

top--;

}

return ret;

}

void display(int stack[], int top)

{ if (top == -1) return;

for(int i = top; i>=0; i--)

cout<<<endl;

cout<<"\n-----------------------\n\n\n";

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

#include<stdio.h>

#include<conio.h>

void main()

{

int top,i,max,a[50],value=23;

clrscr();

printf("value of top");

scanf("%d",&top);

printf("max size of stack");

scanf("%d",&max);

printf("enter the element in stack");

for(i=0;i<top;i++)

scanf("%d",&a[i]);

if(top==max-1)

{

printf("stack is full");

}

else

{

top=top+1;

a[top]=value;

}

printf("\n element of stack after insertion");

for(i=0;i<=top;i++)

{

printf("\n%d",a[i]);

}

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

node *SLSortWiseInsert(node *START, int data)

{

node *newnode;

if(START NULL))

{

printf("Inside this condition\n");

newnode = (node *)malloc(sizeof(node));

newnode->data = data;

newnode->link = NULL;

START->link = newnode;

return START;

}

START->link = SLSortWiseInsert(START->link,data);

return START;

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include<iostream.h>

class sll

{

private:

int data;

sll *next;

public:

sll* insert_one(int,sll*);

sll* delete_one(int,sll*);

void ftraverse(sll*);

void rtraverse(sll*);

void search(int,sll*);

void function();

};

void sll::function()

{

cout<<"******************************************\n";

cout<<"program to implement a singly linked list \n";

cout<<"******************************************\n";

sll * head;

head=NULL;

cout<<"\n\nMENU :\n";

cout<<"1)insertion\n"

<<"2)deletion\n"

<<"3)forward traversal\n"

<<"4)reverse traversal\n"

<<"5)search\n"

<<"6)exit\n\n";

cout<<"Enter your option :";

int opt;

cin>>opt;

int d;

while(opt!=6)

{

switch(opt)

{

case 1:

cout<<"Enter data to the node :";

cin>>d;

head=insert_one(d,head);

cout<<"inserted\n";

break;

case 2:

cout<<"Enter the data to be deleted :";

cin>>d;

head=delete_one(d,head);

break;

case 3:

cout<<"The forward traversal is :\n";

ftraverse(head);

break;

case 4:

cout<<"The reverse traversal is :\n";

rtraverse(head);

cout<<"NULL\n";

break;

case 5:

cout<<"Enter the element to be searched :";

int d;

cin>>d;

search(d,head);

break;

case 6:

break;

}

cout<<"\n\nMENU :\n";

cout<<"1)insertion\n"

<<"2)deletion\n"

<<"3)forward traversal\n"

<<"4)reverse traversal\n"

<<"5)search\n"

<<"6)exit\n\n";

cout<<"Enter your option :";

cin>>opt;

}

}

sll* sll::insert_one(int d,sll* s)

{

sll*NEW;

NEW=new sll;

NEW->data=d;

NEW->next=NULL;

if(s==NULL)

s=NEW;

else

{

sll*s1=s;

while(s1->next!=NULL)

s1=s1->next;

s1->next=NEW;

}

return s;

}

sll* sll::delete_one(int d,sll* s)

{

if(s==NULL)

{

cout<<"list empty \n";

return NULL;

}

if(s->data==d)

s=s->next;

else

{

sll *s1=s;

while( s1->next && s1->next->data!=d )

{

if(s1->next->data==d)

{

cout<<"deleted";

s1->next=s1->next->next;

return s;

}

s1=s1->next;

}

cout<<"not found";

}

return s;

}

void sll::ftraverse(sll* s)

{

sll * s1=s;

while(s1!=NULL)

{

cout<<s1->data<<" -> ";

s1=s1->next;

}

cout<<"NULL\n";

}

void sll::rtraverse(sll* s)

{

if(s==NULL)

return;

else

rtraverse(s->next);

cout<<s->data<<"->";

}

void sll::search(int d,sll* s)

{

while(s!=NULL)

{

if(s->data==d)

{

cout<<"found\n";

return ;

}

s=s->next;

}

cout<<" search unsuccess ful \n";

}

void main()

{

sll list;

list.function();

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Deleting a given node

if( node.next ) node.next.prev = node.prev;

if( node.prev ) node.prev.next = node.next;

if( head node ) tail = node.prev;

delete( node );

Inserting at the head

if( head ) head.prev = node;

node.next = head;

head = node;

Inserting at the tail

if( tail ) tail.next = node;

node.prev = tail;

tail = node;

Inserting after a given node

node.prev = given;

node.next = given.next;

if( given.next) given.next.prev = node;

given.next = node;

Inserting before a given node

node.next = given;

node.prev = given.prev;

if( given.prev ) given.prev.next = node;

given.prev = node;

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to insert or delete a node from doubly linked list?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What operation is supported in constant time by the doubly linked list but not by the singly linked list?

examples:- delete this node (identified by a pointer)- insert a new node before this node- replace this node with another node


Convert single linked list to double linked list?

You copy a singly linked list into a doubly linked list by iterating over the singly linked list and, for each element, calling the doubly linked list insert function.


Why you use doubly link list?

In a doubly linked list, you can iterate backwards as easily as forwards, as each element contains links to both the prior and the following element. You can also insert or delete an element without needing to iterate and remember the prior element's link. This comes at a cost. You are adding storage to each element for the second link, and you are adding processing overhead to the insert and delete operation. You have to determine the tradeoff.


What is best and worst case of time complexity and space complexity of insert and delete operation in singly linked list doubly linked list?

When inserting or extracting at the end of a singly-linked list or at the beginning or end of a doubly-linked list, the complexity is constant time. Inserting or extracting in the middle of a list has linear complexity, with best case O(1) when the insertion or extraction point is already known in advance and a worst case of O(n) when it is not.


Which function removes last element in a list?

If you are using the doubly-linked list from the STL library, then the function call:name_of_list.push_back();should delete the last element.

Related questions

What operation is supported in constant time by the doubly linked list but not by the singly linked list?

examples:- delete this node (identified by a pointer)- insert a new node before this node- replace this node with another node


Convert single linked list to double linked list?

You copy a singly linked list into a doubly linked list by iterating over the singly linked list and, for each element, calling the doubly linked list insert function.


Why you use doubly link list?

In a doubly linked list, you can iterate backwards as easily as forwards, as each element contains links to both the prior and the following element. You can also insert or delete an element without needing to iterate and remember the prior element's link. This comes at a cost. You are adding storage to each element for the second link, and you are adding processing overhead to the insert and delete operation. You have to determine the tradeoff.


What is best and worst case of time complexity and space complexity of insert and delete operation in singly linked list doubly linked list?

When inserting or extracting at the end of a singly-linked list or at the beginning or end of a doubly-linked list, the complexity is constant time. Inserting or extracting in the middle of a list has linear complexity, with best case O(1) when the insertion or extraction point is already known in advance and a worst case of O(n) when it is not.


Which function removes last element in a list?

If you are using the doubly-linked list from the STL library, then the function call:name_of_list.push_back();should delete the last element.


Does each node in a doubly linked list contain a link to the previous as well as the next node?

Yes, each node in a doubly linked list contain a link to the previous as well as the next node. That is the definition of the doubly linked list.


what are the differences between singly link list and doubly link list?

singly linked list stores only the address of next node while doubly linked list stores the address of previous node and next node and hence it is called doubly linked list. In singly linked list only forward traversing is possible while in doubly linked list forward and backward traversal is possible.


What is the difference between doubly linked list and circular linked list?

A doubly linked list is a linked list in which each node knows where both of its neighbors are.A circular linked list is a linked list in which the "tail" of the list is linked to the "root". (Note that both the tail and root of the list are undefined/arbitrary in a circular linked list)Doubly linked lists are actually not necessarily related to circular linked list (aside from both being based on a linked list structure). In fact, you can have a circular doubly linked list, where each node knows where both of its neighbors are andwhere the list wraps around to connect to itself.


C program to implement deque using circular linked list?

You'll need to use a doubly-linked circular list, since otherwise when you pop off the tail element you'll need to whizz all the way round the list to find its predecessor. See the links section for an implementation of a doubly-linked circular list.


Write a algorithm for doubly linked list in c?

sorry


Which operation is perform more efficiently by doubly linked list than by single linked list?

zsd


Algorithm in creating insert method in linked list?

You sort a doubly linked list the same way you sort any other kind of list or array. You implement a procedure to sort the list or array, and that procedure calls the appropriate insert, delete, or move methods of the list or array.