Free Essay

Dont Have Papers Yet

In:

Submitted By itsmevince
Words 818
Pages 4
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 * Delete
Doubly Linked List
Different from a singly linked list, a doubly linked list allows us to go in both directions -- forward and reverse. Such lists allow for a great variety of quick update operations, including insertion and removal at both ends, and in the middle. A node in a doubly linked list stores two references -- a next link, which points to the next node in the list, and a prev link, which points to the previous node in the list.

Operation on Doubly Link List: * Search * Insert * Delete

Sample Program of Singly Linked List

import java.io.*; import java.util.Scanner; class linkedlist { int data; linkedlist next; linkedlist(int value) { this.data = value; } void display() { System.out.println(data); } } class linked { public linkedlist fstnode, lastnode; linked() { fstnode = null; lastnode = null; } /* Insert node or create linked list */ void insertnode(int value) { linkedlist node = new linkedlist(value); node.next = null; if(fstnode == null) { fstnode = lastnode = node; System.out.println("Linked list created successfully!"); } else { lastnode.next = node; lastnode = node; System.out.println("Node inserted successfully!"); } } /* Delete node from linked list */ void delete() { int count = 0, number, i; linkedlist node, node1; Scanner input = new Scanner(System.in); for(node = fstnode; node != null; node = node.next) count++; display(); node = node1 = fstnode; System.out.println(count+" nodes available here!"); System.out.println("Enter the node number which you want to delete:"); number = Integer.parseInt(input.nextLine()); if(number != 1) { if(number <= count) { for(i = 2; i <= number; i++) node = node.next; for(i = 2; i <= number-1; i++) node1 = node1.next; node1.next = node.next; node.next = null; node = null; } else System.out.println("Invalid node number!\n"); } else { fstnode = node.next; node = null; } System.out.println("Node has been deleted successfully!\n"); } /* Display linked list */ void display() { linkedlist node = fstnode; System.out.println("List of node:"); while(node != null) { node.display(); node = node.next; } } }

class singlylinkedlist { public static void main(String args[ ]) { linked list = new linked(); Scanner input = new Scanner(System.in); int op = 0; while(op != 4) { System.out.println("Please select one of the ff options:”); System.out.println (“1. Insert 2. Delete 3. Display 4. Exit"); System.out.println("Enter your choice:"); op = Integer.parseInt(input.nextLine()); switch(op) { case 1: System.out.println("Enter the position value for Linked list:"); list.insertnode(Integer.parseInt(input.nextLine())); break; case 2: list.delete(); break; case 3: list.display(); break; case 4: System.out.println("Bye Bye!"); System.exit(0); break; default: System.out.println("Invalid choice!"); } } } }

Output
Please select one of the ff options:

1. Insert 2. Delete 3. Display 4. Exit
1
4
Linked list created successfully!

Please select one of the ff options:
1. Insert 2. Delete 3. Display 4. Exit
1
5
Node inserted successfully!

Please select one of the ff options:
1. Insert 2. Delete 3. Display 4. Exit
1
6
Node inserted successfully!

Please select one of the ff options:
1. Insert 2. Delete 3. Display 4. Exit
1
7
Node inserted successfully!

Please select one of the ff options:
1. Insert 2. Delete 3. Display 4. Exit
3

List of node:
4
5
6
7

Please select one of the ff options:
1. Insert 2. Delete 3. Display 4. Exit
2
List of node:
4
5
6
7
4 nodes available here!
Enter the position value of Linked list to delete:
3
Node has been deleted successfully!

Similar Documents

Free Essay

I Dont Have a Paper Yet

...The painting “At the Moulin Rouge” in my eyes is a really interesting work of art. The way Henri-de-Toulouse-Lautrec painted the women’s faces is extremely unique to me. He makes the men’s faces normal (normal skin tones and features) the women’s faces are slightly different from the norm. One women has a green face and slightly different features, the other women’s face is yellow and has longer eyes. Henri-de-Toulouse-Lautrec started painting “At the Moulin Rouge” in 1892 and finished in 1895. The painting portrays a group of three men and two women sitting around an old wooden table. The people in the paintings are Edouard Dujardin, La Macarona, Paul Secau, Maurice Guilbert and May Milton. There are many more famous faces in the painting as well. The painting “At the Moulin Rouge” is oil on canvas. Its dimensions are 123cm x 140 cm. The painting is stored at the Art Institute of Chicago. Henri-de-Toulouse-Lautrec was born on the 24th of November in 1864. He was born in a city called Albi in France. He was a member of an aristocratic family. He had a younger brother that died at a year old. Not being able to deal with the mourning of their late son, his parents soon separated after. When Henri turned eight he went to live with his mother in Paris. His family quickly started noticing his artistic talents when he started drawing sketches in his notebooks. In 1875 Henri-de-Toulouse-Lautrec returned to Albi, France because he started having health problems. Henri’s parents were...

Words: 472 - Pages: 2

Premium Essay

Dont Ask Dont Tell Appeal

...Don’t Ask Don’t Tell: Repeal or Not Repeal Up to now, the White House has focused on an aggressive effort to socialize our economy through the bailout of the auto industry, institution of the cap-and-trade system, various stimulus and bailout programs, and a takeover of the healthcare sector. (Bedey) Although these topics are still relevant, recently the motion to repeal “Don’t Ask Don’t Tell” has become one of the most talked about subjects. Before we get into debate, one must know the basic principles of the policy and its history of origin. “Don’t Ask, Don’t Tell, Don’t Pursue, Don’t Harass” (DADTDPDH or DADT for short) is a ban on lesbians, gays and bisexuals serving in the military. DADT is the only law in the United States that authorizes the firing of an American for being gay. There is no other federal, state, or local law like it. DADT is the only law that punishes lesbians, gays and bisexuals for coming out. Many Americans view DADT as a simple agreement with discretion as the key to job security. While this is true to some extent, in the eyes of a homosexual service member, it may not be so simple. An honest statement of one’s sexual orientation to anyone, anywhere, at anytime will lead to being fired. (Service Members Legal Defense Network) DADT was the result of a failed effort by President Clinton to end the ban on gays in the military. The bill was a result of the brutal 1992 murder of Seaman Allen Shindler. Bill Clinton, a candidate at the time, proposed...

Words: 1524 - Pages: 7

Free Essay

Italian Exam Guide

...1 test, students will have 15 minutes to study a stimulus text linked to the general topic area they have chosen. Students must not write on this stimulus, but can make notes on a separate piece of paper. (Notes on key words you have or want to use- these were previously learnt by you). Both the stimulus and any notes must be taken into the exam room, and students can refer to these at any point during the test. (Preferably not for higher marks but if needed referring to them wont be an issue) However, students must not refer to dictionaries or any other resources during the preparation time. (You wont need a dictionary at this point so no problem here right!) * Begin by reading the entire text through (two, three or even 4 times) * Make bullet point notes of the main points of the text * Make a note of any vocabulary from the text which might be useful in discussion of this topic * Do not waste time writing out complete sentences; you will not be allowed to read out long prepared statements anyway (marks are awarded for spontaneity and fluency so please try not to use your notes) * Consider the types of questions which might be asked about the text, and your answers to these questions * Identify any vocabulary you already know that might be useful when answering questions on this topic. The actual exam – As advised by myself. This sections is relatively straightforward ,however, here are a few pointers : 1) Dont rely on flashcards alone...

Words: 3365 - Pages: 14

Premium Essay

Personal Narrative: What I Learned

...Alli did was think what am i going to do i don't wanna go to school and deal with this but i have to i don't really have a choice because i have to go to school it's the law and plus i wanna move onto the next grade”, and as soon as we pulled up i knew it was now or never. As i walked into the school ms. parker and mr. leonard were standing at the door greeting people. I tried to hide so they would see me so i quickly put on my hook and walked in and then that's when it happened. They told me “ take off the hood no hoods inside the building” i didn't want to be disrespectful so i did what they told me too. As soon as i took the hood off and they saw it was me it was a blank stare of silence. Knowing me all i could think to say was good morning. As i walked into the next set of doors i took a glance back all i saw was them give me the look of animosity. I kept...

Words: 1984 - Pages: 8

Free Essay

Bbnnb

...awkward moment when activision realises their cow has run out of milk. Oh yes, all the time. I now regularly go out with a paper bag over my head, and I scream "DON'T LOOK AT ME!!" at strangers all the time. Such a terrible life, it is. Im a 21 year old girl, I joke around too much..so people think that Im immature because of this.. I have so much more to me but no one can see that because im always joking or too excited in social situations. Im so scared everyone is taking me for a joke, I dont want to be perceived that way, Ive been called names like 'monkey,dopey,blonde ect..someone today said to me that they would trust someone else with tickets because im not as grown up as them or as self-conserved..people my age seem so in control of their actions and words whereas I usually speak and act on impulse. I joke so much probably because i'm insecure and scared of being boring...I really want to change..I know the internet is not the place to get advice but I want to know have any of you been through this and changed, do you have any tips for me? and how can I gain my self respect and dignity? Ive been at uni for a few years now and every month that goes by I get more and more bored by the same old studenty lifestyle and conversations that go on around me. I find working people so much more interesting and down to earth on the whole, talking to students feels like a constant image war where you're being sized up and judged and the subject of conversation is usual so boring;...

Words: 1132 - Pages: 5

Free Essay

Alligators

...ALLIGATORS- Organism Physiology Jennifer Ayoub http://www.daufuskieislandconservancy.org/index.php?page=american-alligator The organism that I am going to discuss in this paper is the Alligator. The name "alligator" is an anglicized form of el lagarto, the Spanish term for "the lizard", which early Spanish explorers and settlers in Florida called the alligator. The alligator The alligator is from the crocodilia family and is found normally in the north and even the south. Alligators can grow as big as 14ft and 970 lbs. The largest alligator is in Lousiana and is 72 yrs old. When the alligators reproduce their populations they are found as far in the north as 35 degrees latitude in the freshwater marshes and rivers of coastal North Carolina, and they are also found in the far south as 25 degrees latitude in the Florida Keys. Some of the alligators live in the ocean and they are known as “Salties”. They can't live in the salt water because they dont have the saltwater glands. These different areas are exposed to very different annual thermal cycles. Alligators stop eating when the water temperature drops below 16 degrees C. This anorexia lasts for about 6 months at 35 degrees latitude. In southwest, Louisiana alligators stop feeding in October and they do not resume feeding until the late March or early April. The only time that the alligators grow is in the warmer months, this is their growing season, because they are constantly feeding during this...

Words: 1254 - Pages: 6

Premium Essay

Personal Narrative: Mentally Insane

...boring day here at the ward for the mentally insane. I have done my rounds and sister Merkel has signed off on my papers to get the schizoids new medication.I'll take anything to get them to be quiet in the night. I've been working here for 10, or 12 years It's hard for me to remember. Though I have never been scared of working the nights on a skeleton crew I often worry that the devil will take a waltz through these halls. I say my goodbyes to the help, and when they say ¨Have a good day misser’ Roger¨ I reply with smiling eyes. I always detested how they call me by my first name, but I pay it no attention. They pack into their small cars and drive away down our long serpentined road. I return to the large wooden front...

Words: 1833 - Pages: 8

Premium Essay

Hr Practices

...that slower Chinese population growth would put the Middle Kingdom at a disadvantage. Says Tempest, “the one-child policy in China will play a spoilsport.” The logic is simple. Fast population growth equals more young people, and more young people equals a more dynamic work force. According to the Indian Express, citing India’s Ministry of Labour and Employment, India already has an advantage over more advanced economies. The median age in India in 2000 was 24, compared to 30 in China, 38 in Europe and 41 in creaky old Japan. However, most of those Indians live in the countryside, and it’s no secret that India’s rural population is not sharing in the boom enjoyed by people in other parts of the country. In the past, Asiatech blog readers have written in to debate the merits of India’s development model versus China’s, and the topic of population growth has come up a lot. I’m no fan of China’s one-child policy, and I definitely am not advocating that India adopt anything like it. (Aside from the obvious human-rights problems associated with the policy, some experts argue that the slowdown of China’s population growth came before it even went into effect. For instance, see this article...

Words: 6861 - Pages: 28

Premium Essay

English

...currently recommended levels was very beneficial. Ending a study early is rather unusual. In such cases, studies are stopped not by the investigators, but by an independent group of expert scientists who monitor the trial for evidence of unexpected harm or benefit that requires swift action. When a trial is halted early it is a surprise to the researchers who must not only move quickly to notify the participating doctors and subjects, but also decide how to communicate the results. The usual practice is to make a public announcement with an interpretation of the findings and then finalize the database and write the paper. The N.I.H. followed this playbook, and the media reported that the findings supported more vigorous treatment of high blood pressure, treatment that could be lifesaving. It was reported as major news. The problem is that many details of the study have not been released. It will be months before...

Words: 1110 - Pages: 5

Premium Essay

Respiratory

...Respiratory Disease Paper Milton Dixon HSC/245 Shante Griffin What is Tuberculosis or TB some call it? Tuberculosis or TB is an bacterial disease that goes through the air also normally effects the lungs. Latent tuberculosis (TB) don’t bring on any indications. The indications of active tuberculosis rely on upon where inside the body tuberculosis microbes are developing. Tuberculosis that effects the lungs may bring about a cough that dont go away, torment in the midsection, and hacking up blood or sputum. Other regular manifestations incorporate feeling tired constantly, weight reduction, absence of longing, fever, chills, and sweating around evening time. Still, a few individuals with dynamic TB fell good and only cough sometimes. ("Human Diseases And Conditions", 2015). At the point when individuals with tuberculosis in the lungs or throat hack or either wheeze, they spread microscopic organisms in the air. Other individuals who inhale the same air may get to be contaminated with the microbes, which can stop in the lungs and start to develop. From that point, the microbes can travel through the blood and settle in some other piece of the body that’s including lymph hubs, urinary tract, joints, mind, bones, peritoneum, and heart. Individuals with dynamic tuberculosis are destined to offer it to those they invest a ton of energy with more than a long stretch, for example, relatives, close companions, and collaborators. Indeed, even with close contact...

Words: 733 - Pages: 3

Free Essay

City of Glass

...help of a newfound friend, Sebastian, she uncovers important truths about her family​s past that will help save not only her mother but all those that she holds most dear. ISBN-13: 978-1-4391-5842-5 ISBN-10: 1-4391-5842-8 [1. Supernatural​Fiction. 2. Demonology​Fiction. 3. Magic​Fiction. 4. Vampires​Fiction. 5. New York (N.Y.)​Fiction.] I. Title. PZ7.C5265Ckg 2009 [Fic]​dc22 2008039065 Visit us on the World Wide Web: http://www.SimonSays.com [http://www.SimonSays.com] For my mother. ​I only count the hours that shine.​ Acknowledgments When you look back on writing a book, you cant help but realize what a group effort it all is, and how quickly the whole thing would sink like the Titanic if you didn't have the help of your friends. With that in mind: Thanks to the NB Team and the...

Words: 152069 - Pages: 609

Free Essay

Home Maintenance

...Home Maintenance Paper Team A Pedro Viorato, Santos Nieto, Pao Yang, Samuel Vargas PRG/211 September 19, 2012 Bertram Lee University of Phoenix Home Maintenance Paper Our team has been assigned to come up with a software proposal that will help not only home owners but also those who rent homes. It is common knowledge that without regular home maintenance, whether it is a small or a simple fix could if gone unchecked mushroom into mega expensive repairs that might cause the homeowner to lose their investment. A routine maintenance check off list will ensure that the beauty and durability of a home and also will protect the homeowner’s investment for years to come. The routine maintenance check list that we have chosen to talk about is fixtures, appliances and pluming, which will be broken down into four different categories spring, fall, annual, as needed and as we know sometime we need a professional’s touch the last category is called pro needed. Problem Statement and Solution Our team of software developers won a contract in which we will develop a program to help its users identify recurring tasks to keep their home systems in good working conditions. The program will allow the user to keep a healthy home maintenance and stable home. The program will have different times of the year that it will be performed in order to maintain a good working conditions of the house. The tasks will be performed in the spring, fall, annual, as needed, and pro-needed...

Words: 1414 - Pages: 6

Premium Essay

Social Web Essay

...Social Web Chari N. Clayton INF103 Catherine Doughty 12/16/2010 Social Web The Social Web is so changing and is expanding each and every day. From online education to Social networking, Social Web has become a part of everyone’s life some way, somehow. We are now able to share websites, share photos, and use Social networking as a friend locating tool, free of charge. With all of the options and choices we have available, we can do just about any day-to-day function if we have a computer with a web browser. What is Social Web? The Social web is a specified term for the World Wide Web as a kind of Social Media. The term is currently used to describe how people socialize or interact with each other throughout the web. The Social Web mostly refers to Social networking, MySpace for example, and content-sharing sites (which also offer a Social networking functionality) within Web 2.0. These Social websites are mostly formed around the connections of people of the same interest, but there are several theories that specify exactly how this formation works. There are for example said to be “people focus” websites such as Bebo, Facebook, and MySpace, that focus of social interaction often by making the user create an online identity and a profile. There is also socializing on the web that is typified by “hobby focus”. For example, if one is interested in photography and wants to share this with like-minded people, then there are photography websites...

Words: 2454 - Pages: 10

Premium Essay

Managing Diversity with Organizational Behavior

...Managing Diversity with Organizational Behavior Managing Diversity with Organizational Behavior I believe the president of the United States Barack Obama and many of the 2010 Congressmen and Senators could have learned a lot from this Organizational Behavior class. I believe that their lack of managing diversity training is the root cause of some major turmoil both in and out of the military, and will continue to be for many years to come. In this analysis I would like to focus on some issues with the legislations repeal act of president Bill Clinton and his 1993 legislation’s “Don’t Ask, Don’t Tell” policy and discuss how the 2010 legislation could have managed diversity with less complications. The following analysis is not meant to voice the military nor my personal opinion of the “Don’t Ask, Don’t Tell” policy nor its repeal. This analysis will focus purely on how the 2010 legislation could have managed diversity with less complications (Kreitner & Kinicki, 2010, p. 35) in regards to: the repeal act of the “Don’t Ask, Don’t Tell” policy (Wikipedia, 2012), the Defense of Marriage Act (Beutler, 2011), and the Uniform Code of Military Justice (UCMJ) Article 125: Sodomy (SLDN, 2012), and how these policies are currently not working well together (Beutler, 2011). Diversity represents the multitude of individual differences and similarities that exist among people. Diversity is not an issue of age, race, or gender. Diversity is not an issue of being heterosexual, gay...

Words: 2623 - Pages: 11

Free Essay

Save the Cyclists

...motorcyclists to wear helmets. Since this decision there has been a substantial increase in fatalities of the motorcyclists. Michigan no longer requires motorcyclists to wear protective head gear. The new law basically states that if a rider chooses to not wear a helmet you are to have a $20,000 insurance policy that is supposed to cover your medical and other costs, in the event you are injured in an accident without a helmet on. It has been proven time and time again that $20, 000 will not cover even one day in a critical care unit at a local hospital. Michael Dabbs, president of the Brain Injury Association of Michigan, said the $20,000 insurance coverage that riders are required to buy “would probably buy a part of the day in the ER and intensive care and not much more”. (Durkin, 2013) Motorcyclists feel that if they are required to wear a helmet it takes away their personal freedom. They feel it is a breach of their freedom and motorcyclists stand firm on this belief. Bikers think that if they choose not to wear a helmet, bikers should not have to. Bikers back up their passion about not wearing a helmet by stating that people can smoke drink, take drugs and etc. in America; so why not have the freedom of not wearing a helmet in America. “Helmets, some riders say, take away from the freedom they feel on their bike. The choice to protect their head with a helmet should be theirs, and the government should not “tell them what to do.” It is, after all, their...

Words: 1014 - Pages: 5