Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

Please code using C++ and only use the headers <iostream>. The use of any other headers will not be accepted. Thank you!

Pointers and Linked Lists: Linked Lists
#include <iostream>
current=top;
while(current!=NULL)
{
cout<<current->data<<" ";
current=current->next;
using namespace std;
struct node
{
double data;
node * next;
};
int main()
{
node *top, * current;
int i;
top=new node;
current=top;
top->data=.1;
for (i=2;i<=10;i++)
{
current ->next=new node;
current=current->next;
current ->data=i/10.0;
}
current ->next=NULL;
This makes sure the list
is NULL terminated.
}
cout<<endl;
return 0;
}
output:
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
This NULL
terminates the list.
Now you can write a program that creates a linked list with 26 nodes, fills them with the
letters of the alphabet, and then prints them. Use three separate loops: one for creating,
one for filling, and one for printing. Make sure the last node points to NULL.
expand button
Transcribed Image Text:Pointers and Linked Lists: Linked Lists #include <iostream> current=top; while(current!=NULL) { cout<<current->data<<" "; current=current->next; using namespace std; struct node { double data; node * next; }; int main() { node *top, * current; int i; top=new node; current=top; top->data=.1; for (i=2;i<=10;i++) { current ->next=new node; current=current->next; current ->data=i/10.0; } current ->next=NULL; This makes sure the list is NULL terminated. } cout<<endl; return 0; } output: 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 This NULL terminates the list. Now you can write a program that creates a linked list with 26 nodes, fills them with the letters of the alphabet, and then prints them. Use three separate loops: one for creating, one for filling, and one for printing. Make sure the last node points to NULL.
16: linkedList.cpp) Write a program in three parts. The
first part should create a linked list of 26 nodes. The second
part should fill the list with the letters of the alphabet. The
third part should print the contents of the linked list.
expand button
Transcribed Image Text:16: linkedList.cpp) Write a program in three parts. The first part should create a linked list of 26 nodes. The second part should fill the list with the letters of the alphabet. The third part should print the contents of the linked list.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education