Write the definition of the linkedListKeepLast function. (Please write the following in C, Thank you)
The purpose of the function is to create a new linked list containing
the last node in each linked list in the hash table beginning with the first linked list.
The rest of the nodes are to be displayed to the screen, then returned to the heap.
Example:
If the user enters the following keys:
201, 102, 233, 567, 456, 654, 465, 645, quit
list at index 0 is empty
list at index 1 is not empty:
201
102
567
list at index 2 is not empty:
233
list at index 3 is empty
list at index 4 is not empty:
456
654
465
645
Deleted nodes:
--> at index 0:
--> at index 1: 201 102
--> at index 2:
--> at index 3:
--> at index 4: 456 654 465
The final linked list contains:
567
233
645
Written by:
*/
#include <stdio.h>
#include <stdlib.h> // malloc(), free(), exit()
#include <string.h>
#define NUMPOINTERS 5
typedef struct node STUDENTREC;
struct node
{
char id[10];
struct node *next;
};
// Function Declarations
int hash(char id[]);
STUDENTREC *insert(char id[],
STUDENTREC *student_body[],
int hashval);
void traverse(STUDENTREC *student_body[]);
void displayLL(STUDENTREC *list, char *description);
STUDENTREC *linkedListKeepLast(STUDENTREC *student_body[]);
int main (void)
{
STUDENTREC *student_body[NUMPOINTERS] = {NULL};
STUDENTREC *person;
STUDENTREC *endList;
char id[10];
int hashval;
printf(" ~*~ Hashing using collision resolution by chaining ~*~\n");
printf("\t Enter Student ID (or quit): ");
scanf("%s", id);
while(strcmp(id, "quit"))
{
hashval = hash(id);
person = insert(id, student_body, hashval);
if (person) // not NULL => duplicate
{
printf("Duplicate record!\n");
}
printf("\t Enter Student ID (or quit): ");
scanf("%s", id);
}
traverse(student_body);
endList = linkedListKeepLast(student_body);
displayLL(endList, "New List");
traverse(student_body);
return 0;
}
/*
The purpose of the function is to create a new linked list containing
the last node in each linked list in the hash table beginning with the first linked list.
The rest of the nodes are to be displayed to the screen, then returned to the heap.
*/
STUDENTREC *linkedListKeepLast(STUDENTREC *student_body[])
{
STUDENTREC *newList = NULL;
/* *********************************************************
Write your code here
Get the job done without calling other linked list functions
********************************************************* */
return newList;
}
/***************************************************
Hash Student ID by summing the cubes
of the ASCII value of characters and then take
the modulo of this sum.
*/
int hash(char id[])
{
long sum = 0;
while (*id) // != '\0'
{
sum += *id * *id * *id;
id++;
}
return sum % NUMPOINTERS;
}
/***************************************************
Insert a new Social Security number into the
array of student records, at index equal to
hashvalue
*/
STUDENTREC *insert(char id[],
STUDENTREC *student_body[],
int hashval)
{
STUDENTREC **mover; // Use ** to write elegant co.
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfformicreation
Assignment is :
\"Page 349-350 #4 and #5 Use the \"Linked List lab\" you have been working on in class and add
the two functions the questions are asking you to develop: divideMid and divideAt. Be sure to
include comments Use meaningful identifier names (constants where appropriate) Do not work
together; no two people should have identical work!?!? Turn in .cpp file AND Turn in a \"print-
screen\' of your output (press \"print-screen\' on keyboard, then \'paste\' in MS-Word)\"
How do you solve QUESTION #5 in the book data structures using c++ by D.S. Malik in Visiual
Studios using the linked list below with what is being asked? Please need help
Linked list :
#include
#include
using namespace std;
struct nodeType
{
int info;
nodeType *link;
};
void createList(nodeType*& first, nodeType*& last);
void printList(nodeType*& first);
void insertFront(nodeType*& first);
void insertBack(nodeType*& last);
void deleteFirst(nodeType*& first);
void deleteLast(nodeType*& last, nodeType* first);
int main()
{
nodeType *first, *last;
int num;
createList(first, last);
int choice;
while(true)
{
cout<<\"1. Insert Front.\ 2. Insert Last.\ 3. Delete Front.\ 4. Delete Last.\ 5. Print List.\ 6. Exit.\
\";
cout<<\"Enter your choice: \";
cin>>choice;
switch(choice)
{
case 1: insertFront(first); break;
case 2: insertBack(last); break;
case 3: deleteFirst(first); break;
case 4: deleteLast(last, first); break;
case 5: printList(first); break;
case 6: return 0;
default: cout<<\"Invalid menu option. Try again.\"<>number;
while (number != -999)
{
newNode = new nodeType; // create new node
newNode->info = number;
newNode->link = NULL;
if (first == NULL)
{
first = newNode;
last = newNode;
}
else
{
last->link = newNode;
last = newNode;
}
cout<<\"Enter an integer (-999 to stop): \";
cin>>number;
} // end of while-loop
} // end of build list function
void deleteFirst(nodeType*& first)
{
nodeType *temp;
temp= first;
first= temp->link;
delete temp;
return;
}
void deleteLast(nodeType*& last, nodeType* current)
{
nodeType *temp;
while(current->link != NULL)
{
temp=current;
current=current->link;
}
temp=last;
current->link=NULL;
delete temp;
last = current;
return;
}
void insertFront(nodeType*& front)
{
int num;
cout<<\"\ Enter the number to insert: \";
cin>>num;
nodeType *newNode = new nodeType;
newNode->info=num;
newNode->link= front;
front= newNode;
return;
}
void insertBack(nodeType*& last)
{
int num;
cout<<\"\ Enter the number to insert: \";
cin>>num;
nodeType *newNode = new nodeType;
newNode->info=num;
newNode->link= NULL;
last->link= newNode;
last = newNode;
return;
}
void printList(nodeType*& first)
{
cout<<\"Inside printList...printing linked list...\ \"<info << \" \";
current = current->link;
}
cout<
#include
using namespace std;
struct nodeType
{
int info;
nodeType *link;
};
void createList(nodeType*& first, nodeType*& last);
void printList(nodeType*& first);
void insertFront(nodeType*& first);
void insertBack(nodeType*& last);
void deleteFirst(nodeType*& first);
void dele.
maincpp Build and procees a sorted linked list of Patie.pdfadityastores21
main.cpp
/*
Build and procees a sorted linked list of Patient objects.
The list is sorted in ascending order by name.
Assume that the name is unique.
*/
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cctype>
#include "LinkedList.h"
using namespace std;
void buildList(const string &filename, LinkedList &list);
void deleteManager(LinkedList &list);
void searchManager(const LinkedList &list);
void displayManager(const LinkedList &list);
int main() {
string inputFileName;
LinkedList list;
cout << "Enter file name: ";
getline(cin, inputFileName);
buildList(inputFileName, list);
displayManager(list);
searchManager(list);
deleteManager(list);
displayManager(list);
return 0;
}
/*
This function reads data from a file and inserts them
into a sorted linked list. The list is sorted in ascending order by name
*/
void buildList(const string &filename, LinkedList &list) {
ifstream inFile(filename);
cout << "Reading data from "" << filename << ""n";
if(!inFile) {
cout << "Error opening the input file: ""<< filename << """ << endl;
exit(EXIT_FAILURE);
}
string id;
int year;
string name;
int amount;
string line;
while (getline(inFile, line)) {
stringstream temp(line);
temp >> id >> year;
temp.ignore();
getline(temp, name, ';');
temp >> amount;
// create a Sales object and initialize it with data from file
/* Write your code here */
// call insert to insert this new Sales object into the sorted list
/* Write your code here */
}
inFile.close();
}
/*
Delete manager: delete items from the list until the user enters Q to quit
deleting
Input Parameter: list
*/
void deleteManager(LinkedList &list) {
string target = "";
cout << " Delete" << endl;
cout << "========" << endl;
while(target != "Q") {
cout << "Enter a name (or Q to stop deleting):" << endl;
getline(cin, target);
target[0] = toupper(target[0]);
if(target != "Q") {
if(list.deleteNode(target))
cout << target << " has been deleted!" << endl;
else
cout << target << " not found!" << endl;
}
}
cout << "___________________END DELETE SECTION_____" << endl;
}
/*
Search manager: search the list until the user enters Q to quit searching
Input Parameter: list
*/
void searchManager(const LinkedList &list) {
string target = "";
Sales obj;
cout << " Search" << endl;
cout << "========" << endl;
/* Write your code here */
cout << "___________________END SEARCH SECTION _____" << endl;
}
/*
Display manager: all, average, or year hired reports including header and footer where
appropriate,
depending on the user's choice;
displays the number of nodes (always)
Input Parameter: list
*/
void displayManager(const LinkedList &list) {
// Sub-functions of displayManager()
void showMenu(void);
string getOption(void);
void showHeader(string line);
string line = "==== ==================== =============n";
string option;
showMenu();
option = getOption();
while(option[0] != 'Q') {
switch (option[0]) {
case 'A':
showHeader(line);
list.displayList();
cout << line;
break;
case 'G':
cou.
In this lab, we will write an application to store a deck of cards i.pdfcontact41
In this lab, we will write an application to store a deck of cards in a linked list, and then write
methods to sort and shuffle the deck.
Copy your completed LinkedList class from Lab 4 into the LinkedList.java file below.
Complete all methods of the Card class as described by the Javadoc comments. The class
contains both a suit and a rank. A suit is one of the categories into which the cards of a deck are
divided. The rank is the relative importance of the card within its suit.
Note that the Card constructor must convert any rank and suit letters to uppercase.
For the equals() method, be sure to follow the steps outlined in Lesson 4. How to implement the
compareTo() method is also covered in Lesson 4.
Note that you are not allowed to add any additional methods or member variables to this class or
you will not receive credit for this assignment.
Complete all methods of the CardApp class in the CardApp.java file as described by the Javadoc
comments.
You may add as many methods as you would like to this file, but are not allowed to add any
additional member variables.
The CardApp program must prompt for and allow the user to enter the name of any input file as
shown in the Example output below.
Implement the shuffle() method as specified in the comments for shuffle(). After you have
shuffled the deck of cards, write the result into a file named shuffled.txt.
Implement the sort() method using bubble sort from Lesson 4. First sort by suit in alphabetical
order and then by rank from 2 to A. The pseudocode for bubble sort is as follows:
After you have sorted the deck of cards, write the result to a file named sorted.txt.
The CardApp.java file also contains the main() method of the application. Use Develop mode to
test your CardApp code along with your Card and LinkedList code.
All input and output files must contain a list of cards, with each card stored on its own line. See
the example files cards1.txt and cards2.txt for example file formats.
[[[cards1.txt]]]
2H
3H
4H
5H
6H
7H
8H
9H
10H
JH
[[[cards2.txt]]]
AS
2S
3S
4S
5S
6S
7S
8S
9S
10S
JS
QS
KS
AC
2C
3C
4C
5C
6C
7C
8C
9C
10C
JC
QC
KC
AH
2H
3H
4H
5H
6H
7H
8H
9H
10H
JH
QH
KH
AD
2D
3D
4D
5D
6D
7D
8D
9D
10D
JD
QD
KD
[[[CardApp.java]]]
/**
* CardApp.java
* @author Your name
* @author Partner's name
* CIS 22C, Applied Lab 1
*/
public class CardApp {
private LinkedList list;
/**
* User interface prompts user, reads and writes files.
*/
public static void main(String[] args) {
}
/**
* Default constructor to initialize the deck
*/
public CardApp() {
}
/**
* Inserts a new Card into the deck
* @param card a playing Card
*/
public void addCard(Card card) {
}
/**
* Shuffles cards following this algorithm:
* First swaps first and last card
* Next, swaps every even card with the card 3
* nodes away from that card. Stops when it
* reaches the 3rd to last node
* Then, swaps ALL cards with the card that is
* 2 nodes away from it, starting at the 2nd card
* and stopping stopping at the 3rd to last node
*/
public vo.
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
StackInterface
/**
An interface for the ADT stack.
Do not modify this file
*/
package PJ2;
public interface StackInterface
{
/** Gets the current number of data in this stack.
@return the integer number of entries currently in the stack*/
public int size();
/** Adds a new data to the top of this stack.
@param aData an object to be added to the stack */
public void push(T aData);
/** Removes and returns this stack\'s top data.
@return either the object at the top of the stack or,
if the stack is empty before the operation, null */
public T pop();
/** Retrieves this stack\'s top data.
@return either the data at the top of the stack or
null if the stack is empty */
public T peek();
/** Detects whether this stack is empty.
@return true if the stack is empty */
public boolean empty();
/** Removes all data from this stack */
public void clear();
} // end StackInterface
SimpleLinkedStack.java
/**
A class of stacks whose entries are stored in a chain of nodes.
Implement all methods in SimpleLinkedStack class using
the inner Node class.
Main Reference : text book or class notes
Do not change or add data fields
Do not add new methods
You may access Node object fields directly, i.e. data and next
*/
package PJ2;
public class SimpleLinkedStack implements StackInterface
{
// Data fields
private Node topNode; // references the first node in the chain
private int count; // number of data in this stack
public SimpleLinkedStack()
{
// add stataments
} // end default constructor
public void push(T newData)
{
// add stataments
} // end push
public T peek()
{
// add stataments
return null;
} // end peek
public T pop()
{
// add stataments
return null;
} // end pop
public boolean empty()
{
// add stataments
return false;
} // end empty
public int size()
{
// add stataments
return -1;
} // end isEmpty
public void clear()
{
// add stataments
} // end clear
public String toString()
{
// add stataments
// note: data class in stack must implement toString() method
// return a list of data in Stack, separate them with \',\'
return \"\";
}
/****************************************************
private inner node class
Do not modify this class!!
you may access data and next directly
***************************************************/
private class Node
{
private T data; // entry in list
private Node next; // link to next node
private Node (T dataPortion)
{
data = dataPortion;
next = null; // set next to NULL
} // end constructor
private Node (T dataPortion, Node nextNode)
{
data = dataPortion;
next = nextNode; // set next to refer to nextNode
} // end constructor
} // end Node
/****************************************************
Do not modify: Stack test
****************************************************/
public static void main (String args[])
{
System.out.println(\"\ \"+
\"*******************************************************\ \"+
\"Sample Expected output:\ \"+
\"\ \"+
\"OK: stack is empty\ \"+
\"Push 3 data: 10, 30, 50\ \"+
\"Print stack [50,30,10,]\ \"+
\"OK: sta.
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
How do you stop infinite loop? Because I believe that it is making an infinite circular list.
c++ code:
Here is the list class:
#ifndef LIN_J_LIST
#define LIN_J_LIST
typedef unsigned int uint;
#include
#include
using namespace std;
/**
* a simplified generic singly linked list class to illustrate C++ concepts
* @author Jerry Lin
* @version 2/17/17
*/
template< typename Object >
class List
{
private:
/**
* A class to store data and provide a link to the next node in the list
*/
class Node
{
public:
/**
* The constructor
* @param data the data to be stored in this node
*/
explicit Node( const Object & data )
: data{ data }, next{ nullptr } {}
Object data;
Node * next;
};
public:
/**
* The constructor for an empty list
*/
List()
: size{ 0 }, first{ nullptr }, last{ nullptr } {}
/**
* the copy constructor-creates and copy the list
*/
List( List && rhs ) = delete;
List( const List & rhs )
{
count = 0;
size = 0;
if(rhs.size != 0)
{
push_front(rhs.front());
Node * current = rhs.first;
Node * tempNode = first;
size++;
while(current->next != nullptr)
{
current = current->next;
Node *newNode = new Node(current->data); //transfer the data. basic op.
count++;
tempNode->next = newNode;
last = newNode;
tempNode = tempNode->next;
size++;
}
}
// you document and implement this method
}
/**
* the operator= method-copies the list
*/
List & operator=( List && rhs) = delete;
List & operator=( const List & rhs )
{
count = 0;
size = 0;
if( size != 0 )
{
Node * current = first;
Node * temp;
while( current != nullptr )
{
temp = current;
current = current->next;
delete temp;
}
}
if(rhs.size!= 0)
{
push_front(rhs.front());
Node * current = rhs.first;
Node * tempNode = first; //create a temporary to store
size++;
while(current -> next != nullptr)
{
current = current->next;
Node *newNode = new Node(current->data); //transfer the data. basic op
count++;
tempNode->next = newNode;
last = newNode;
tempNode = tempNode -> next;
size++;
}
}
return *this;
// you document and implement this method
}
/**
* accessor
* @return count
*/
int get_count() const
{
return count;
}
/**
* The destructor that gets rid of everything that\'s in the list and
* resets it to empty. If the list is already empty, do nothing.
*/
~List()
{
if( size != 0 )
{
Node * current = first;
Node * temp;
while( current != nullptr )
{
temp = current;
current = current->next;
delete temp;
}
}
}
/**
* Put a new element onto the beginning of the list
* @param item the data the new element will contain
*/
void push_front( const Object& item )
{
Node * new_node = new Node( item );//basic op.
if(is_empty())
{
last = new_node;
}
else
{
new_node->next = first;
}
first = new_node;
size++;
/* you complete the rest */
}
/**
* Remove the element that\'s at the front of the list. Causes an
* assertion error if the list is empty.
*/
void pop_front()
{
assert( !is_empty() );
Node * temp = first;
if( first == last )
{
first = last = nullptr;
}
else
{
first = first->next;
}
delete temp;
size--;
}
/**
* Accessor to return the da.
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfpoblettesedanoree498
C++: Doubly-Linked Lists
The goal of the exercise is to implement a class List of doubly- linked lists.
My goal is to implement the class in a file doubly-linked.cpp.
The class List implements lists using the following structures for list ele- ments:
struct Node { int val ;
Node next;
Node prev; };
Each Node contains a value (an integer) and two pointers: one meant to point to the next element
of the list and one meant to point to the previous element in the list. The class provides the
following methods that you need to implement:
• A constructor and a destructor, with no arguments;
• void insert(int n): insert an integer at the end of the list;
• void reverse(): reverse the list;
• void print(): print the list to cout in the same format as the input (i.e. integers separated by
spaces);
doubly-linked.h
#ifndef __dll__
#define __dll__
#include
using namespace std;
// Basic structure to store elements of a list
struct Node {
int val; // contains the value
Node * next; // pointer to the next element in the list
Node * prev; // pointer to the previous element in the list
};
// Class List
class List {
public:
List(void); // Constructor
~List(void); // Destructor
void insert(int n); // This should insert n in the list
void reverse(void); // This should reverse the list
void print(void); // This shoiuld print the list
private:
Node * first; // Pointer to the first (if any) element in the list
};
#endif
main.cpp
#include
#include \"doubly-linked.h\"
using namespace std;
int main(void){
List l;
int n;
while(cin >> n){
l.insert(n);
}
// Print list as read from cin
l.print();
// Reverse the list and print it
l.reverse();
l.print();
// Reverse again and print it
l.reverse();
l.print();
return 0;
}
Solution
#include
using namespace std;
/* Linked list structure */
struct list {
struct list *prev;
int data;
struct list *next;
} *node = NULL, *first = NULL, *last = NULL, *node1 = NULL, *node2 = NULL;
class linkedlist {
public:
/* Function for create/insert node at the beginning of Linked list */
void insrt_frnt() {
list *addBeg = new list;
cout << \"Enter value for the node:\" << endl;
cin >> addBeg->data;
if(first == NULL) {
addBeg->prev = NULL;
addBeg->next = NULL;
first = addBeg;
last = addBeg;
cout << \"Linked list Created!\" << endl;
}
else {
addBeg->prev = NULL;
first->prev = addBeg;
addBeg->next = first;
first = addBeg;
cout << \"Data Inserted at the beginning of the Linked list!\" << endl;
}
}
/* Function for create/insert node at the end of Linked list */
void insrt_end() {
list *addEnd = new list;
cout << \"Enter value for the node:\" << endl;
cin >> addEnd->data;
if(first == NULL) {
addEnd->prev = NULL;
addEnd->next = NULL;
first = addEnd;
last = addEnd;
cout << \"Linked list Created!\" << endl;
}
else {
addEnd->next = NULL;
last->next = addEnd;
addEnd->prev = last;
last = addEnd;
cout << \"Data Inserted at the end of the Linked list!\" << endl;
}
}
/* Function for Display Linked list */
void display() {
node = first;
cout << \"List of data in L.
Complete in JavaCardApp.javapublic class CardApp { private.pdfMAYANKBANSAL1981
Complete in Java
CardApp.java
public class CardApp {
private LinkedList list;
/**
* User interface prompts user, reads and writes files.
*/
public static void main(String[] args) {
}
/**
* Default constructor to initialize the deck
*/
public CardApp() {
}
/**
* Inserts a new Card into the deck
* @param card a playing Card
*/
public void addCard(Card card) {
}
/**
* Shuffles cards following this algorithm:
* First swaps first and last card
* Next, swaps every even card with the card 3
* nodes away from that card. Stops when it
* reaches the 3rd to last node
* Then, swaps ALL cards with the card that is
* 2 nodes away from it, starting at the 2nd card
* and stopping stopping at the 3rd to last node
*/
public void shuffle() {
}
/**
* Implements the bubble sort algorithm
* to sort cardList into sorted order, first by suit
* (alphabetical order)
* then by rank from 2 to A
*/
public void sort() {
}
/**
* Returns the deck of cards with each card separated
* by a blank space and a new line character at the end.
* @return The deck of cards as a string.
*/
@Override public String toString() {
return "";
}
}
Card.java
public class Card implements Comparable{
private String rank;
private String suit;
/**
* Constructor for the Card class
* @param rank the rank of card from 2 to A
* @param suit the suit of card C, D, H, or S
*/
public Card(String rank, String suit) {
}
/**
* Returns the card's rank
* @return rank a rank from 2 (low) to A (high)
*/
public String getRank() {
return "";
}
/**
* Returns the card's suit
* @return C, D, H, or S
*/
public String getSuit() {
return "";
}
/**
* Updates the card's rank
* @param rank a new rank
*/
public void setRank(String rank) {
}
/**
* Updates the card's suit
* @param suit the new suit
*/
public void setSuit(String suit) {
}
/**
* Concatenates rank and suit
* @return card rank and suit
*/
@Override public String toString() {
return "";
}
/**
* Overrides the equals method for Card
* Compares rank and suit and
* follows the equals formula given in
* Lesson 4 and also in Joshua Block's text
* @param obj another Object to compare for
* equality
* @return whether obj is a Card and, if so,
* of equal rank and suit
*/
@Override public boolean equals(Object obj) {
return false;
}
/**
* Orders two cards first by suit (alphabetically)
* Next by rank. "A" is considered the high card
* Order goes 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A
* @param card another Card to compare to this Card
* @return a negative number if this comes before c
* and a positive number if c comes before this
* and 0 if this and c are equal according to the above
* equals method
*/
@Override public int compareTo(Card card) {
return -1;
}
}
}
LinkedList.Java
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterato.
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfformicreation
Assignment is :
\"Page 349-350 #4 and #5 Use the \"Linked List lab\" you have been working on in class and add
the two functions the questions are asking you to develop: divideMid and divideAt. Be sure to
include comments Use meaningful identifier names (constants where appropriate) Do not work
together; no two people should have identical work!?!? Turn in .cpp file AND Turn in a \"print-
screen\' of your output (press \"print-screen\' on keyboard, then \'paste\' in MS-Word)\"
How do you solve QUESTION #5 in the book data structures using c++ by D.S. Malik in Visiual
Studios using the linked list below with what is being asked? Please need help
Linked list :
#include
#include
using namespace std;
struct nodeType
{
int info;
nodeType *link;
};
void createList(nodeType*& first, nodeType*& last);
void printList(nodeType*& first);
void insertFront(nodeType*& first);
void insertBack(nodeType*& last);
void deleteFirst(nodeType*& first);
void deleteLast(nodeType*& last, nodeType* first);
int main()
{
nodeType *first, *last;
int num;
createList(first, last);
int choice;
while(true)
{
cout<<\"1. Insert Front.\ 2. Insert Last.\ 3. Delete Front.\ 4. Delete Last.\ 5. Print List.\ 6. Exit.\
\";
cout<<\"Enter your choice: \";
cin>>choice;
switch(choice)
{
case 1: insertFront(first); break;
case 2: insertBack(last); break;
case 3: deleteFirst(first); break;
case 4: deleteLast(last, first); break;
case 5: printList(first); break;
case 6: return 0;
default: cout<<\"Invalid menu option. Try again.\"<>number;
while (number != -999)
{
newNode = new nodeType; // create new node
newNode->info = number;
newNode->link = NULL;
if (first == NULL)
{
first = newNode;
last = newNode;
}
else
{
last->link = newNode;
last = newNode;
}
cout<<\"Enter an integer (-999 to stop): \";
cin>>number;
} // end of while-loop
} // end of build list function
void deleteFirst(nodeType*& first)
{
nodeType *temp;
temp= first;
first= temp->link;
delete temp;
return;
}
void deleteLast(nodeType*& last, nodeType* current)
{
nodeType *temp;
while(current->link != NULL)
{
temp=current;
current=current->link;
}
temp=last;
current->link=NULL;
delete temp;
last = current;
return;
}
void insertFront(nodeType*& front)
{
int num;
cout<<\"\ Enter the number to insert: \";
cin>>num;
nodeType *newNode = new nodeType;
newNode->info=num;
newNode->link= front;
front= newNode;
return;
}
void insertBack(nodeType*& last)
{
int num;
cout<<\"\ Enter the number to insert: \";
cin>>num;
nodeType *newNode = new nodeType;
newNode->info=num;
newNode->link= NULL;
last->link= newNode;
last = newNode;
return;
}
void printList(nodeType*& first)
{
cout<<\"Inside printList...printing linked list...\ \"<info << \" \";
current = current->link;
}
cout<
#include
using namespace std;
struct nodeType
{
int info;
nodeType *link;
};
void createList(nodeType*& first, nodeType*& last);
void printList(nodeType*& first);
void insertFront(nodeType*& first);
void insertBack(nodeType*& last);
void deleteFirst(nodeType*& first);
void dele.
maincpp Build and procees a sorted linked list of Patie.pdfadityastores21
main.cpp
/*
Build and procees a sorted linked list of Patient objects.
The list is sorted in ascending order by name.
Assume that the name is unique.
*/
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cctype>
#include "LinkedList.h"
using namespace std;
void buildList(const string &filename, LinkedList &list);
void deleteManager(LinkedList &list);
void searchManager(const LinkedList &list);
void displayManager(const LinkedList &list);
int main() {
string inputFileName;
LinkedList list;
cout << "Enter file name: ";
getline(cin, inputFileName);
buildList(inputFileName, list);
displayManager(list);
searchManager(list);
deleteManager(list);
displayManager(list);
return 0;
}
/*
This function reads data from a file and inserts them
into a sorted linked list. The list is sorted in ascending order by name
*/
void buildList(const string &filename, LinkedList &list) {
ifstream inFile(filename);
cout << "Reading data from "" << filename << ""n";
if(!inFile) {
cout << "Error opening the input file: ""<< filename << """ << endl;
exit(EXIT_FAILURE);
}
string id;
int year;
string name;
int amount;
string line;
while (getline(inFile, line)) {
stringstream temp(line);
temp >> id >> year;
temp.ignore();
getline(temp, name, ';');
temp >> amount;
// create a Sales object and initialize it with data from file
/* Write your code here */
// call insert to insert this new Sales object into the sorted list
/* Write your code here */
}
inFile.close();
}
/*
Delete manager: delete items from the list until the user enters Q to quit
deleting
Input Parameter: list
*/
void deleteManager(LinkedList &list) {
string target = "";
cout << " Delete" << endl;
cout << "========" << endl;
while(target != "Q") {
cout << "Enter a name (or Q to stop deleting):" << endl;
getline(cin, target);
target[0] = toupper(target[0]);
if(target != "Q") {
if(list.deleteNode(target))
cout << target << " has been deleted!" << endl;
else
cout << target << " not found!" << endl;
}
}
cout << "___________________END DELETE SECTION_____" << endl;
}
/*
Search manager: search the list until the user enters Q to quit searching
Input Parameter: list
*/
void searchManager(const LinkedList &list) {
string target = "";
Sales obj;
cout << " Search" << endl;
cout << "========" << endl;
/* Write your code here */
cout << "___________________END SEARCH SECTION _____" << endl;
}
/*
Display manager: all, average, or year hired reports including header and footer where
appropriate,
depending on the user's choice;
displays the number of nodes (always)
Input Parameter: list
*/
void displayManager(const LinkedList &list) {
// Sub-functions of displayManager()
void showMenu(void);
string getOption(void);
void showHeader(string line);
string line = "==== ==================== =============n";
string option;
showMenu();
option = getOption();
while(option[0] != 'Q') {
switch (option[0]) {
case 'A':
showHeader(line);
list.displayList();
cout << line;
break;
case 'G':
cou.
In this lab, we will write an application to store a deck of cards i.pdfcontact41
In this lab, we will write an application to store a deck of cards in a linked list, and then write
methods to sort and shuffle the deck.
Copy your completed LinkedList class from Lab 4 into the LinkedList.java file below.
Complete all methods of the Card class as described by the Javadoc comments. The class
contains both a suit and a rank. A suit is one of the categories into which the cards of a deck are
divided. The rank is the relative importance of the card within its suit.
Note that the Card constructor must convert any rank and suit letters to uppercase.
For the equals() method, be sure to follow the steps outlined in Lesson 4. How to implement the
compareTo() method is also covered in Lesson 4.
Note that you are not allowed to add any additional methods or member variables to this class or
you will not receive credit for this assignment.
Complete all methods of the CardApp class in the CardApp.java file as described by the Javadoc
comments.
You may add as many methods as you would like to this file, but are not allowed to add any
additional member variables.
The CardApp program must prompt for and allow the user to enter the name of any input file as
shown in the Example output below.
Implement the shuffle() method as specified in the comments for shuffle(). After you have
shuffled the deck of cards, write the result into a file named shuffled.txt.
Implement the sort() method using bubble sort from Lesson 4. First sort by suit in alphabetical
order and then by rank from 2 to A. The pseudocode for bubble sort is as follows:
After you have sorted the deck of cards, write the result to a file named sorted.txt.
The CardApp.java file also contains the main() method of the application. Use Develop mode to
test your CardApp code along with your Card and LinkedList code.
All input and output files must contain a list of cards, with each card stored on its own line. See
the example files cards1.txt and cards2.txt for example file formats.
[[[cards1.txt]]]
2H
3H
4H
5H
6H
7H
8H
9H
10H
JH
[[[cards2.txt]]]
AS
2S
3S
4S
5S
6S
7S
8S
9S
10S
JS
QS
KS
AC
2C
3C
4C
5C
6C
7C
8C
9C
10C
JC
QC
KC
AH
2H
3H
4H
5H
6H
7H
8H
9H
10H
JH
QH
KH
AD
2D
3D
4D
5D
6D
7D
8D
9D
10D
JD
QD
KD
[[[CardApp.java]]]
/**
* CardApp.java
* @author Your name
* @author Partner's name
* CIS 22C, Applied Lab 1
*/
public class CardApp {
private LinkedList list;
/**
* User interface prompts user, reads and writes files.
*/
public static void main(String[] args) {
}
/**
* Default constructor to initialize the deck
*/
public CardApp() {
}
/**
* Inserts a new Card into the deck
* @param card a playing Card
*/
public void addCard(Card card) {
}
/**
* Shuffles cards following this algorithm:
* First swaps first and last card
* Next, swaps every even card with the card 3
* nodes away from that card. Stops when it
* reaches the 3rd to last node
* Then, swaps ALL cards with the card that is
* 2 nodes away from it, starting at the 2nd card
* and stopping stopping at the 3rd to last node
*/
public vo.
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
StackInterface
/**
An interface for the ADT stack.
Do not modify this file
*/
package PJ2;
public interface StackInterface
{
/** Gets the current number of data in this stack.
@return the integer number of entries currently in the stack*/
public int size();
/** Adds a new data to the top of this stack.
@param aData an object to be added to the stack */
public void push(T aData);
/** Removes and returns this stack\'s top data.
@return either the object at the top of the stack or,
if the stack is empty before the operation, null */
public T pop();
/** Retrieves this stack\'s top data.
@return either the data at the top of the stack or
null if the stack is empty */
public T peek();
/** Detects whether this stack is empty.
@return true if the stack is empty */
public boolean empty();
/** Removes all data from this stack */
public void clear();
} // end StackInterface
SimpleLinkedStack.java
/**
A class of stacks whose entries are stored in a chain of nodes.
Implement all methods in SimpleLinkedStack class using
the inner Node class.
Main Reference : text book or class notes
Do not change or add data fields
Do not add new methods
You may access Node object fields directly, i.e. data and next
*/
package PJ2;
public class SimpleLinkedStack implements StackInterface
{
// Data fields
private Node topNode; // references the first node in the chain
private int count; // number of data in this stack
public SimpleLinkedStack()
{
// add stataments
} // end default constructor
public void push(T newData)
{
// add stataments
} // end push
public T peek()
{
// add stataments
return null;
} // end peek
public T pop()
{
// add stataments
return null;
} // end pop
public boolean empty()
{
// add stataments
return false;
} // end empty
public int size()
{
// add stataments
return -1;
} // end isEmpty
public void clear()
{
// add stataments
} // end clear
public String toString()
{
// add stataments
// note: data class in stack must implement toString() method
// return a list of data in Stack, separate them with \',\'
return \"\";
}
/****************************************************
private inner node class
Do not modify this class!!
you may access data and next directly
***************************************************/
private class Node
{
private T data; // entry in list
private Node next; // link to next node
private Node (T dataPortion)
{
data = dataPortion;
next = null; // set next to NULL
} // end constructor
private Node (T dataPortion, Node nextNode)
{
data = dataPortion;
next = nextNode; // set next to refer to nextNode
} // end constructor
} // end Node
/****************************************************
Do not modify: Stack test
****************************************************/
public static void main (String args[])
{
System.out.println(\"\ \"+
\"*******************************************************\ \"+
\"Sample Expected output:\ \"+
\"\ \"+
\"OK: stack is empty\ \"+
\"Push 3 data: 10, 30, 50\ \"+
\"Print stack [50,30,10,]\ \"+
\"OK: sta.
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
How do you stop infinite loop? Because I believe that it is making an infinite circular list.
c++ code:
Here is the list class:
#ifndef LIN_J_LIST
#define LIN_J_LIST
typedef unsigned int uint;
#include
#include
using namespace std;
/**
* a simplified generic singly linked list class to illustrate C++ concepts
* @author Jerry Lin
* @version 2/17/17
*/
template< typename Object >
class List
{
private:
/**
* A class to store data and provide a link to the next node in the list
*/
class Node
{
public:
/**
* The constructor
* @param data the data to be stored in this node
*/
explicit Node( const Object & data )
: data{ data }, next{ nullptr } {}
Object data;
Node * next;
};
public:
/**
* The constructor for an empty list
*/
List()
: size{ 0 }, first{ nullptr }, last{ nullptr } {}
/**
* the copy constructor-creates and copy the list
*/
List( List && rhs ) = delete;
List( const List & rhs )
{
count = 0;
size = 0;
if(rhs.size != 0)
{
push_front(rhs.front());
Node * current = rhs.first;
Node * tempNode = first;
size++;
while(current->next != nullptr)
{
current = current->next;
Node *newNode = new Node(current->data); //transfer the data. basic op.
count++;
tempNode->next = newNode;
last = newNode;
tempNode = tempNode->next;
size++;
}
}
// you document and implement this method
}
/**
* the operator= method-copies the list
*/
List & operator=( List && rhs) = delete;
List & operator=( const List & rhs )
{
count = 0;
size = 0;
if( size != 0 )
{
Node * current = first;
Node * temp;
while( current != nullptr )
{
temp = current;
current = current->next;
delete temp;
}
}
if(rhs.size!= 0)
{
push_front(rhs.front());
Node * current = rhs.first;
Node * tempNode = first; //create a temporary to store
size++;
while(current -> next != nullptr)
{
current = current->next;
Node *newNode = new Node(current->data); //transfer the data. basic op
count++;
tempNode->next = newNode;
last = newNode;
tempNode = tempNode -> next;
size++;
}
}
return *this;
// you document and implement this method
}
/**
* accessor
* @return count
*/
int get_count() const
{
return count;
}
/**
* The destructor that gets rid of everything that\'s in the list and
* resets it to empty. If the list is already empty, do nothing.
*/
~List()
{
if( size != 0 )
{
Node * current = first;
Node * temp;
while( current != nullptr )
{
temp = current;
current = current->next;
delete temp;
}
}
}
/**
* Put a new element onto the beginning of the list
* @param item the data the new element will contain
*/
void push_front( const Object& item )
{
Node * new_node = new Node( item );//basic op.
if(is_empty())
{
last = new_node;
}
else
{
new_node->next = first;
}
first = new_node;
size++;
/* you complete the rest */
}
/**
* Remove the element that\'s at the front of the list. Causes an
* assertion error if the list is empty.
*/
void pop_front()
{
assert( !is_empty() );
Node * temp = first;
if( first == last )
{
first = last = nullptr;
}
else
{
first = first->next;
}
delete temp;
size--;
}
/**
* Accessor to return the da.
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfpoblettesedanoree498
C++: Doubly-Linked Lists
The goal of the exercise is to implement a class List of doubly- linked lists.
My goal is to implement the class in a file doubly-linked.cpp.
The class List implements lists using the following structures for list ele- ments:
struct Node { int val ;
Node next;
Node prev; };
Each Node contains a value (an integer) and two pointers: one meant to point to the next element
of the list and one meant to point to the previous element in the list. The class provides the
following methods that you need to implement:
• A constructor and a destructor, with no arguments;
• void insert(int n): insert an integer at the end of the list;
• void reverse(): reverse the list;
• void print(): print the list to cout in the same format as the input (i.e. integers separated by
spaces);
doubly-linked.h
#ifndef __dll__
#define __dll__
#include
using namespace std;
// Basic structure to store elements of a list
struct Node {
int val; // contains the value
Node * next; // pointer to the next element in the list
Node * prev; // pointer to the previous element in the list
};
// Class List
class List {
public:
List(void); // Constructor
~List(void); // Destructor
void insert(int n); // This should insert n in the list
void reverse(void); // This should reverse the list
void print(void); // This shoiuld print the list
private:
Node * first; // Pointer to the first (if any) element in the list
};
#endif
main.cpp
#include
#include \"doubly-linked.h\"
using namespace std;
int main(void){
List l;
int n;
while(cin >> n){
l.insert(n);
}
// Print list as read from cin
l.print();
// Reverse the list and print it
l.reverse();
l.print();
// Reverse again and print it
l.reverse();
l.print();
return 0;
}
Solution
#include
using namespace std;
/* Linked list structure */
struct list {
struct list *prev;
int data;
struct list *next;
} *node = NULL, *first = NULL, *last = NULL, *node1 = NULL, *node2 = NULL;
class linkedlist {
public:
/* Function for create/insert node at the beginning of Linked list */
void insrt_frnt() {
list *addBeg = new list;
cout << \"Enter value for the node:\" << endl;
cin >> addBeg->data;
if(first == NULL) {
addBeg->prev = NULL;
addBeg->next = NULL;
first = addBeg;
last = addBeg;
cout << \"Linked list Created!\" << endl;
}
else {
addBeg->prev = NULL;
first->prev = addBeg;
addBeg->next = first;
first = addBeg;
cout << \"Data Inserted at the beginning of the Linked list!\" << endl;
}
}
/* Function for create/insert node at the end of Linked list */
void insrt_end() {
list *addEnd = new list;
cout << \"Enter value for the node:\" << endl;
cin >> addEnd->data;
if(first == NULL) {
addEnd->prev = NULL;
addEnd->next = NULL;
first = addEnd;
last = addEnd;
cout << \"Linked list Created!\" << endl;
}
else {
addEnd->next = NULL;
last->next = addEnd;
addEnd->prev = last;
last = addEnd;
cout << \"Data Inserted at the end of the Linked list!\" << endl;
}
}
/* Function for Display Linked list */
void display() {
node = first;
cout << \"List of data in L.
Complete in JavaCardApp.javapublic class CardApp { private.pdfMAYANKBANSAL1981
Complete in Java
CardApp.java
public class CardApp {
private LinkedList list;
/**
* User interface prompts user, reads and writes files.
*/
public static void main(String[] args) {
}
/**
* Default constructor to initialize the deck
*/
public CardApp() {
}
/**
* Inserts a new Card into the deck
* @param card a playing Card
*/
public void addCard(Card card) {
}
/**
* Shuffles cards following this algorithm:
* First swaps first and last card
* Next, swaps every even card with the card 3
* nodes away from that card. Stops when it
* reaches the 3rd to last node
* Then, swaps ALL cards with the card that is
* 2 nodes away from it, starting at the 2nd card
* and stopping stopping at the 3rd to last node
*/
public void shuffle() {
}
/**
* Implements the bubble sort algorithm
* to sort cardList into sorted order, first by suit
* (alphabetical order)
* then by rank from 2 to A
*/
public void sort() {
}
/**
* Returns the deck of cards with each card separated
* by a blank space and a new line character at the end.
* @return The deck of cards as a string.
*/
@Override public String toString() {
return "";
}
}
Card.java
public class Card implements Comparable{
private String rank;
private String suit;
/**
* Constructor for the Card class
* @param rank the rank of card from 2 to A
* @param suit the suit of card C, D, H, or S
*/
public Card(String rank, String suit) {
}
/**
* Returns the card's rank
* @return rank a rank from 2 (low) to A (high)
*/
public String getRank() {
return "";
}
/**
* Returns the card's suit
* @return C, D, H, or S
*/
public String getSuit() {
return "";
}
/**
* Updates the card's rank
* @param rank a new rank
*/
public void setRank(String rank) {
}
/**
* Updates the card's suit
* @param suit the new suit
*/
public void setSuit(String suit) {
}
/**
* Concatenates rank and suit
* @return card rank and suit
*/
@Override public String toString() {
return "";
}
/**
* Overrides the equals method for Card
* Compares rank and suit and
* follows the equals formula given in
* Lesson 4 and also in Joshua Block's text
* @param obj another Object to compare for
* equality
* @return whether obj is a Card and, if so,
* of equal rank and suit
*/
@Override public boolean equals(Object obj) {
return false;
}
/**
* Orders two cards first by suit (alphabetically)
* Next by rank. "A" is considered the high card
* Order goes 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A
* @param card another Card to compare to this Card
* @return a negative number if this comes before c
* and a positive number if c comes before this
* and 0 if this and c are equal according to the above
* equals method
*/
@Override public int compareTo(Card card) {
return -1;
}
}
}
LinkedList.Java
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterato.
package singlylinkedlist; public class Node { public String valu.pdfamazing2001
package singlylinkedlist;
public class Node {
public String value;
public Node next;
public Node(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
}
SingleyLinkedList.java :
package singlylinkedlist;
import java.io.*;
import java.util.*;
/**
* Defines the interface for a singly-linked list.
*
*/
public interface SinglyLinkedList {
/**
* @return Reference to the first node. If the list is empty, this method
* returns null.
*/
public Node getFirst();
/**
* @return Reference to the last node . If the list is empty, this method
* returns null.
*/
public Node getLast();
/**
* @return Number of nodes in the list
*/
public int size();
/**
* @return true if the list has no nodes; false otherwise
*/
public boolean isEmpty();
/**
* Removes all nodes in the list.
*/
public void clear();
/**
* Inserts a new node with the given value after cursor.
*
* @param cursor
* The node to insert after. Set this to null to insert value as
the
* new first Node.
* @param value
* The value to insert
* @return a reference to the newly inserted Node
*/
public Node insert(Node cursor, String value);
/**
* Inserts a new node with the given value at the "end" of the list.
*
* @param value
* @return a reference to the newly inserted Node
*/
public Node append(String value);
/**
* Removes the node after the specified Node (cursor) from the list.
*
* @param cursor
* A reference to the Node to remove.
*/
public void removeAfter(Node cursor);
/**
* Returns a reference to the first Node containing the key, starting from
the
* given Node.
*
* @param start
* @param key
* @return a reference to the first Node containing the key
*/
public Node find(Node start, String key);
/**
* Prints the values of all the items in a list
*/
public void printWholeList();
}
SinglyLinkedTester.java:
package sbccunittest;
import static java.lang.Math.*;
import static java.lang.System.*;
import static org.apache.commons.lang3.StringUtils.*;
import static org.junit.Assert.*;
import static sbcc.Core.*;
import java.io.*;
import java.lang.reflect.*;
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;
import org.apache.commons.lang3.*;
import org.junit.*;
import org.w3c.dom.ranges.*;
import sbcc.*;
import singlylinkedlist.*;
/**
* 09/16/2021
*
* @author sstrenn
*
*/
public class SinglyLinkedListTester {
public static String newline = System.getProperty("line.separator");
public static int totalScore = 0;
public static int extraCredit = 0;
public static boolean isZeroScore = false;
public static String scorePreamble = "";
@BeforeClass
public static void beforeTesting() {
totalScore = 0;
extraCredit = 0;
}
@AfterClass
public static void afterTesting() {
if (isZeroScore) {
totalScore = 0;
extraCredit = 0;
}
println(scorePreamble + "Estimated score (w/o late penalties, etc.) is:
" + totalScore + " out of 25.");
// If the project follows the naming convention, save the results in a
folder on
// the desktop. (Alex Kohanim)
try {
String directory =
substri.
For each task, submit your source java code file.(1) Objective Im.pdfdhavalbl38
For each task, submit your source java code file.
(1) Objective: Implement Link List
Write a class that maintains the scores for a game application. Implement the addition and
removal function to update the database. The gamescore.txt contains player’ name and score data
record fields separated by comma. For Removal function, uses the name field to select record to
remove the game score record.
Download – List.java, LList.java, Dlink.java, GameEntry.java, gamescore.txt
(a)Read gamescore.txt to initialize the Linked list in sorted order. (1 point)
(b)Provide Remove and Add function for user to update the sorted linked list. (1 point)
(2)Add a reverse function to the LList.java class to reverse the order of the linked list. (2 points).
---------------------------------------------------------------------------------------------------------------------
-----------------------------------------
//gamescore.txt
Mike,1105
Rob,750
Paul,720
Anna,660
Rose,590
Jack,510
--------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------
//DLink.java
/** Source code example for \"A Practical Introduction to Data
Structures and Algorithm Analysis, 3rd Edition (Java)\"
by Clifford A. Shaffer
Copyright 2008-2011 by Clifford A. Shaffer
*/
/** Doubly linked list node */
class DLink {
private E element; // Value for this node
private DLink next; // Pointer to next node in list
private DLink prev; // Pointer to previous node
/** Constructors */
DLink(E it, DLink p, DLink n)
{ element = it; prev = p; next = n; }
DLink(DLink p, DLink n) { prev = p; next = n; }
/** Get and set methods for the data members */
DLink next() { return next; }
DLink setNext(DLink nextval)
{ return next = nextval; }
DLink prev() { return prev; }
DLink setPrev(DLink prevval)
{ return prev = prevval; }
E element() { return element; }
E setElement(E it) { return element = it; }
}
--------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------
//GameEntry.java
public class GameEntry {
protected String name;
protected int score;
public GameEntry(String n, int s) {
name = n;
score = s;
}
public String getName() {return name;}
public int getScore() {return score;}
public String toString() {
return \"(\"+name+\",\"+score+\")\";
}
}
--------------------------------------------------------------------------------------------------------------------
----------------------------------
//List.java
/** Source code example for \"A Practical Introduction to Data
Structures and Algorithm Analysis, 3rd Edition (Java)\"
by Clifford A. Shaffer
Copyright 2008-2011 by Clifford A. Shaffer
*/
/** List ADT */
public interface List {
/** Remove all contents from the list, so it is once again
empty. Client is responsible for reclaiming storage
used by the list elements. */
p.
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfmallik3000
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD
OR REMOVE NAME. DO NOT HARD CODE NAME. AGAIN MAKE SURE THE
PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR REMOVE NAME. PLEASE
MAKE SURE THE CODE RUNS WITHOUT ANY ERRORS.
Write a class that maintains the scores for a game application. Implement the addition and
removal function to update the database. The gamescore.txt contains player’ name and score data
record fields separated by comma. For Removal function, uses the name field to select record to
remove the game score record.
Use the List.java, LList.java, Dlink.java, GameEntry.java and gamescore.txt found below
Read gamescore.txt to initialize the Linked list in sorted order by score.
Ask the user to add or remove users to update the sorted linked list.
Display “Name exist” when add an exist name to the list.
Display “Name does not exist” when remove a name not on the list.
List.java File:
/** Source code example for \"A Practical Introduction to Data
Structures and Algorithm Analysis, 3rd Edition (Java)\"
by Clifford A. Shaffer
Copyright 2008-2011 by Clifford A. Shaffer
*/
/** List ADT */
public interface List
{
/**
* Remove all contents from the list, so it is once again empty. Client is
* responsible for reclaiming storage used by the list elements.
*/
public void clear();
/**
* Insert an element at the current location. The client must ensure that
* the list\'s capacity is not exceeded.
*
* @param item
* The element to be inserted.
*/
public void insert(E item);
/**
* Append an element at the end of the list. The client must ensure that
* the list\'s capacity is not exceeded.
*
* @param item
* The element to be appended.
*/
public void append(E item);
/**
* Remove and return the current element.
*
* @return The element that was removed.
*/
public E remove();
/** Set the current position to the start of the list */
public void moveToStart();
/** Set the current position to the end of the list */
public void moveToEnd();
/**
* Move the current position one step left. No change if already at
* beginning.
*/
public void prev();
/**
* Move the current position one step right. No change if already at end.
*/
public void next();
/** @return The number of elements in the list. */
public int length();
/** @return The position of the current element. */
public int currPos();
/**
* Set current position.
*
* @param pos
* The position to make current.
*/
public void moveToPos(int pos);
/** @return The current element. */
public E getValue();
}
LList.java File:
/**
* Source code example for \"A Practical Introduction to Data Structures and
* Algorithm Analysis, 3rd Edition (Java)\" by Clifford A. Shaffer Copyright
* 2008-2011 by Clifford A. Shaffer
*/
// Doubly linked list implementation
class LList implements List
{
private DLink head; // Pointer to list header
private DLink tail; // Pointer to last element in list
protected DLink curr; // Pointer ahead of current element
int cnt; // Size of list
// Constructors
LList(int size)
{
th.
Modify the Simple lexer program given in the link below to .pdfadityaenterprise32
Modify the Simple lexer program given in the link below to:
Add tokens so that all the tokens in the program from Activity 1 of this module are represented (75
points).
The output of your program should specify the type of token in words (Identifier, Keyword ...etc)
not a number (25 points).
Print each token on a separate line.
main.cpp
front.in
(sum + 47) / total
/**
* This the example lexical analyzer code in pages 173 - 177 of the
* textbook,
*
* Sebesta, R. W. (2012). Concepts of Programming Languages.
* Pearson, 10th edition.
*
*/
/* front.c - a lexical analyzer system for simple arithmetic expressions */
#include <stdio.h>
#include <ctype.h>
/* Global declarations */
/* Variables */
int charClass;
char lexeme [100];
char nextChar;
int lexLen;
int nextToken;
FILE *in_fp;
/* Function declarations */
void addChar();
void getChar();
void getNonBlank();
int lex();
/* Character classes */
#define LETTER 0
#define DIGIT 1
#define UNKNOWN 99
/* Token codes */
#define INT_LIT 10
#define IDENT 11
#define ASSIGN_OP 20
#define ADD_OP 21
#define SUB_OP 22
#define MULT_OP 23
#define DIV_OP 24
#define LEFT_PAREN 25
#define RIGHT_PAREN 26
/******************************************************/
/* main driver */
int main()
{
/* Open the input data file and process its contents */
if ((in_fp = fopen("front.in", "r")) == NULL) {
printf("ERROR - cannot open front.in n");
} else {
getChar();
do {
lex();
} while (nextToken != EOF);
}
return 0;
}
/*****************************************************/
/* lookup - a function to lookup operators and parentheses and return the
* token */
int lookup(char ch) {
switch (ch) {
case '(':
addChar();
nextToken = LEFT_PAREN;
break;
case ')':
addChar();
nextToken = RIGHT_PAREN;
break;
case '+':
addChar();
nextToken = ADD_OP;
break;
case '-':
addChar();
nextToken = SUB_OP;
break;
case '*':
addChar();
nextToken = MULT_OP;
break;
case '/':
addChar();
nextToken = DIV_OP;
break;
default:
addChar();
nextToken = EOF;
break;
}
return nextToken;
}
/*****************************************************/
/* addChar - a function to add nextChar to lexeme */
void addChar() {
if (lexLen <= 98) {
lexeme[lexLen++] = nextChar;
lexeme[lexLen] = 0;
} else {
printf("Error - lexeme is too long n");
}
}
/*****************************************************/
/* getChar - a function to get the next character of input and determine its
* character class */
void getChar() {
if ((nextChar = getc(in_fp)) != EOF) {
if (isalpha(nextChar))
charClass = LETTER;
else if (isdigit(nextChar))
charClass = DIGIT;
else charClass = UNKNOWN;
} else {
charClass = EOF;
}
}
/*****************************************************/
/* getNonBlank - a function to call getChar until it returns a non-whitespace
* character */
void getNonBlank() {
while (isspace(nextChar)) getChar();
}
/*****************************************************/
/* lex - a simple lexical analyzer for arithmetic expressions */
int lex() {
lexLen = 0;
getNonBlank();
switch (charClass) {
/* Par.
There are a number of errors in the following program- All errors are.docxclarkjanyce
There are a number of errors in the following program.
All errors are located in main() and structure definitions.
Function declarations and definitions are correct!
Locate all errors, fix them (as shown below), run the program and save its output
as a comment at the end of the source file.
Example:
int num = 10;
int *ptr;
num = &ptr; // <== Error: Comment the line and write the correct line below
// Write a short justification where appropriate
// num = &ptr; // Error #1
ptr = #
Name:
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define DUMMY_TRAILER '\177'
// octal ASCII code of the
// last character in the ASCII table
#define NUM_CITIES 10
typedef struct
{
char name[12];
int temperature[5];
} CITY;
// Stack and Queue Node
typedef struct node NODE;
struct node
{
CITY city;
node *next;
};
// Doubly Linked List Node
typedef struct d_node D_NODE;
struct d_node
{
CITY city;
NODE *forw;
NODE *back;
};
// Stack Functions
NODE *push(NODE *stack, const CITY *pStu);
NODE *pop(NODE **stack);
// Queue Functions
void enqueue(NODE **queue, NODE **rear, const CITY *pStu);
NODE *dequeue(NODE **queue, NODE **rear);
// Doubly Linked List Functions
D_NODE *init_list(void);
int insert(D_NODE *list, const CITY *pStu);
void traverse_forw(D_NODE *list);
void traverse_back(D_NODE *list);
// Other Functions
void printCity(const CITY *pCity);
int main (void)
{
CITY cList[NUM_CITIES] =
{
{"Cupertino", {88, 89, 87, 85, 89}},
{"Flagstaff", {81, 80, 88, 89, 89}},
{"Los Angeles", {87, 88, 89, 89, 90}},
{"Philadelphia", {96, 99, 99, 90, 95}},
{"Phoenix", {106, 109, 109, 100, 105}},
{"Portland", {89, 90, 85, 89, 90}},
{"Reno", {108, 105, 109, 100, 108}},
{"Salem", {85, 90, 85, 89, 90}},
{"Tucson", {107, 100, 109, 100, 108}},
{"Yreka", {101, 109, 100, 108, 109}}
};
NODE *stack = NULL;
NODE *top = NULL;
NODE *queue = NULL, *rear = NULL;
NODE *front;
D_NODE *list;
list = init_list();
// build stack and queue with data from an array of CITY structures
srand((unsigned int)time(NULL));
int count = rand() % 10;
for ( int n = 0; n < count; n++)
{
int i = rand() % NUM_CITIES;
int duplicate = insert(list, &cList[i]);
if(duplicate)
{
// already in the list!
push(stack, &cList[i]);
enqueue(&queue, &rear, cList[i]);
}
}
// display list
printf("\nLIST contents (forwards):\n");
traverse_forw(list);
printf("\nLIST contents (backwards):\n");
traverse_back(list);
// display stack
if (top)
{
printf("\nSTACK contents from top to bottom:\n");
while ((top = pop(stack)))
{
printCity(top->city);
}
}
else
printf ("Empty Stack!\n");
// display queue
if (front)
{
printf("\nQUEUE contents from front to rear:\n");
while ((front = dequeue( queue, rear)))
{
printCity(front->city);
}
}
else
printf ("Empty Queue!\n");
return 0;
}
/***************************************************
Displays the fileds of a CIS_CLASS structure
Pre pCls - a pointer to a CIS_CLASS structure
Post
*/
void printCity(const CITY *pCity)
{
printf("%-20s %3d\n", pCity->name, pCity->temperatur.
C++ Background Circular Linked List A circular linked list.pdfsaradashata
C++
Background:
Circular Linked List: A circular linked list is a linked list where a non-empty list has no null pointers.
Unless empty, each node has a pointer to the next node, and the last node points back to the first
node.
Assigment:
Write a cpp program that will serve the purpose of a test driver for previously written CLinkedList.h
file. Your program will:
1) Create a choice menu and prompt the user for input. Must be case insensitive!
2) Read the input and call for functions outside of main, in order to perform operations chosen by
the user. These functions involve: Inserting Interger, Removing Interger, Forward Print and
Backward Print.
Requirements and Notes:
1. Forwards Print does not require a subfunction in order to produce output. All the other
operations must call corresponding subfunctions.
2. Nodes of the circular list must be arranged in ascending order.
3. User Input must be processed case insensitive, and implemented using the loop.
4. Document your code completely.
5. CLinkedList.h file contains 3 classes.
- Circular linked lists class with following member functions: constructor, copy constructor,
destructor, assignment operator, insert and remove.
- Node class included in the file header.
- A list iterator class provides a public interface to the list. The pointer points at nodes in the linked
list. Its member functions are as follows:
Constructor: Assigns the linked list data member to the parameter, a reference to a circular linked
list.
begin() sets the iterator to the first node of the linked list (or NULL if the list is empty)
isEmpty() returns whether or not the wrapped linked list is empty
isFirstNode() returns whether the present node is the first node of the linked list
isLastNode() returns whether the present node is the last node of the linked list
operator*() returns the data of the node currently pointed at. (You need 2)
operator++() pre-increment operator advances the pointer to the next node in the list, if there is
one
operator++(int) post-increment operator advances the pointer to the next node in the list, if there
is one
6. Insert function must give feedback where it says the position of where the int was inserted for
example: "Inserting 25 in the middle."
7. Remove function must give either one of these types of feedback:
- "Removing 25" if the int given by the user was found in the list
-"Cannot find 25" if it was not. The program will then move the user back to the choice menu.
Files:
// File: Node.h
// Singly-linked list node definition/implementation (also good for circular)
#ifndef NODE_H
#define NODE_H
// Need to prototype template classes if they are to be friends
template <typename eltType> class CLinkedList;
template <typename eltType> class CListItr;
template <typename eltType> class Node
{ private:
Node(eltType info, Node* link = NULL ) :
data(info), next(link)
{};
eltType data;
Node *next;
friend class CLinkedList<eltType>;
friend class CListItr<eltType>;
};
#endif
// File: CLinkedList.h
.
Background Circular Linked List A circular linked list is .pdfaaseletronics2013
Background:
Circular Linked List: A circular linked list is a linked list where a non-empty list has no null pointers.
Unless empty, each node has a pointer to the next node, and the last node points back to the first
node.
Assigment:
Write a cpp program that will serve the purpose of a test driver for previously written CLinkedList.h
file. Your program will:
1) Create a choice menu and prompt the user for input. Must be case insensitive!
2) Read the input and call for functions outside of main, in order to perform operations chosen by
the user. These functions involve: Inserting Interger, Removing Interger, Forward Print and
Backward Print.
Requirements and Notes:
1. Forwards Print does not require a subfunction in order to produce output. All the other
operations must call corresponding subfunctions.
2. Nodes of the circular list must be arranged in ascending order.
3. User Input must be processed case insensitive, and implemented using the loop.
4. Document your code completely.
5. CLinkedList.h file contains 3 classes.
- Circular linked lists class with following member functions: constructor, copy constructor,
destructor, assignment operator, insert and remove.
- Node class included in the file header.
- A list iterator class provides a public interface to the list. The pointer points at nodes in the linked
list. Its member functions are as follows:
Constructor: Assigns the linked list data member to the parameter, a reference to a circular linked
list.
begin() sets the iterator to the first node of the linked list (or NULL if the list is empty)
isEmpty() returns whether or not the wrapped linked list is empty
isFirstNode() returns whether the present node is the first node of the linked list
isLastNode() returns whether the present node is the last node of the linked list
operator*() returns the data of the node currently pointed at. (You need 2)
operator++() pre-increment operator advances the pointer to the next node in the list, if there is
one
operator++(int) post-increment operator advances the pointer to the next node in the list, if there
is one
6. Insert function must give feedback where it says the position of where the int was inserted for
example: "Inserting 25 in the middle."
7. Remove function must give either one of these types of feedback:
- "Removing 25" if the int given by the user was found in the list
-"Cannot find 25" if it was not. The program will then move the user back to the choice menu.
Files:
// File: Node.h
// Singly-linked list node definition/implementation (also good for circular)
#ifndef NODE_H
#define NODE_H
// Need to prototype template classes if they are to be friends
template <typename eltType> class CLinkedList;
template <typename eltType> class CListItr;
template <typename eltType> class Node
{ private:
Node(eltType info, Node* link = NULL ) :
data(info), next(link)
{};
eltType data;
Node *next;
friend class CLinkedList<eltType>;
friend class CListItr<eltType>;
};
#endif
// File: CLinkedList.h
// C.
write recursive function that calculates and returns the length of a.pdfarpitcomputronics
write recursive function that calculates and returns the length of a linked list
Solution
// C code to determine length of linked list recursively
#include
#include
// node of linked list
struct node
{
int key;
struct node* next;
};
// push key to linked list
void push(struct node** root, int new_element)
{
struct node* nodeNew = (struct node*) malloc(sizeof(struct node));
nodeNew->key = new_element;
nodeNew->next = (*root);
(*root) = nodeNew;
}
// recursively get length of linked list
int lengthLinkedlist(struct node* root)
{
// base case
if (root == NULL)
return 0;
// recursively call the function
return 1 + lengthLinkedlist(root->next);
}
int main()
{
struct node* root = NULL;
push(&root, 11);
push(&root, 34);
push(&root, 4);
push(&root, 23);
push(&root, 14);
push(&root, 88);
push(&root, 56);
push(&root, 84);
push(&root, 6);
/* Check the count function */
printf(\"Length of Linked list: %d\ \", lengthLinkedlist(root));
return 0;
}
/*
output:
Length of Linked list: 9
*/.
Please code in C language- Please do part 1 and 2- Do not recycle answ.docxcgraciela1
Please code in C language. Please do part 1 and 2. Do not recycle answers and implement the starter code
Starter code:
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "linkedlist.h"
// print an error message by an error number, and return
// the function does not exit from the program
// the function does not return a value
void error_message(enum ErrorNumber errno) {
char *messages[] = {
"OK",
"Memory allocaton failed.",
"Deleting a node is not supported.",
"The number is not on the list.",
"Sorting is not supported.",
"Reversing is not supported.",
"Token is too long.",
"A number should be specified after character d, a, or p.",
"Token is not recognized.",
"Invalid error number."};
if (errno < 0 || errno > ERR_END)
errno = ERR_END;
printf("linkedlist: %s\n", messages[errno]);
}
node *new_node(int v) {
node *p = malloc(sizeof(node)); // Allocate memory
if (p == NULL) {
error_message(ERR_NOMEM);
exit(-1);
}
// Set the value in the node.
p->v = v; // you could do (*p).v
p->next = NULL;
return p; // return
}
node *prepend(node *head, node *newnode) {
newnode->next = head;
return newnode;
}
node *find_node(node *head, int v) {
while (head != NULL) {
if (head->v == v)
return head;
head = head->next;
}
return head;
}
node *find_last(node *head) {
if (head != NULL) {
while (head->next != NULL)
head = head->next;
}
return head;
}
node *append(node *head, node *newnode) {
node *p = find_last(head);
newnode->next = NULL;
if (p == NULL)
return newnode;
p->next = newnode;
return head;
}
node *delete_list(node *head) {
while (head != NULL) {
node *p = head->next;
free(head);
head = p;
}
return head;
}
void print_list(node *head) {
printf("[");
while (head) {
printf("%d, ", head->v);
head = head->next;
}
printf("]\n");
}
void print_node(node *p) {
printf("%p: v=%-5d next=%p\n", p, p->v, p->next);
}
void print_list_details(node *head) {
while (head) {
print_node(head);
head = head->next;
}
}
// functions that have not been implemented
node *delete_node(node *head, int v) {
// TODO
error_message(ERR_NODELETE);
return head;
}
/*
* Given a pointer to the head node of an acyclic list, change the
* next links such that the nodes are linked in reverse order.
* Allocating new nodes or copying values from one node to another
* is not allowed, but you may use additional pointer variables.
* Return value is a pointer to the new head node.
*/
node *reverse_list(node *head) {
// TODO
error_message(ERR_NOREVERSE);
return head;
}
Part 1. Delete node. The linked list example we have studied in lecture maintains a singly linked list of integers. The program can append and prepend integers to the list. Type help in the program to see a list of commands. Note that if the number to be added is already on the list, the program prints the information about the node that stores the number and does not add the number twice. The list is displayed every time an integer is processed. Currently, the program does not support the delete function..
1- The design of a singly-linked list below is a picture of the functi (1).pdfafgt2012
1. The design of a singly-linked list
below is a picture of the function that needs to be used
below is the code of the above picture:
#include <string>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define defaultSize 100
void Assert(bool val, string s)
{
if (!val)
{ // Assertion failed -- close the program
cout << "Assertion Failed: " << s << endl;
exit(-1);
}
}
template <typename E>
class Link {
public:
E element; // Value for this node
Link *next; // Pointer to next node in list
// Constructors
Link(const E& elemval, Link<E>* nextval = NULL)
{ element = elemval; next = nextval; }
Link(Link<E>* nextval =NULL) { next = nextval; }
};
template <typename E>
class LList: public Link<E> {
private:
Link<E>* head;// Intialization helper method
Link<E>* tail;// Pointer to last element
Link<E>* curr;// Access to current element
int cnt;// Size of list
void init(){// Intialization helper method
curr = tail = head = new Link<E>;
cnt = 0;
}
void removeall() {// Return link nodes to free store
while(head != NULL) {
curr = head;
head = head->next;
delete curr;
}
}
public:
LList(int size=defaultSize) { init(); }// Constructor
~LList() { removeall(); }// Destructor
void print() const;// Print list contents
void clear() { removeall(); init(); }// Clear list
// Insert "it" at current position
void insert(const E& it) {
curr->next = new Link<E>(it, curr->next);
if (tail == curr) tail = curr->next; // New tail
cnt++;
}
void append(const E& it) { // Append "it" to list
tail = tail->next = new Link<E>(it, NULL);
cnt++;
}
// Remove and return current element
E remove() {
Assert(curr->next != NULL, "No element");
E it = curr->next->element; // Remember value
Link<E>* ltemp = curr->next; // Remember link node
if (tail == curr->next) tail = curr; // Reset tail
curr->next = curr->next->next; // Remove from list
delete ltemp; // Reclaim space
cnt--; // Decrement the count
return it;
}
void moveToStart()// Place curr at list start
{ curr = head; }
void moveToEnd() // Place curr at list end
{ curr = tail; }
void prev(){
if (curr == head) return;
Link<E>* temp = head;
while (temp->next!=curr) temp=temp->next;
curr = temp;
}
void next(){ if (curr != tail) curr = curr->next; }
int length() const { return cnt; }
int currPos() const {
Link<E>* temp = head;
int i;
for (i=0; curr != temp; i++)
temp = temp->next;
return i;
}
void moveToPos(int pos){
Assert ((pos>=0)&&(pos<=cnt), "Position out of range");
curr = head;
for(int i=0; i<pos; i++) curr = curr->next;
}
const E& getValue() const {
Assert(curr->next != NULL, "No value");
return curr->next->element;
}
};
completed this code to fulfill the requirement below:
Write a function to insert an integer into a singly-linked list of elements arranged from largest to
smallest. Requires that elements remain ordered after insertion.
2. The design of array-based stack
below is a picture of the function that needs to be used
below is the code of the above picture:
#include <string.h>
#.
03/.DS_Store
__MACOSX/03/._.DS_Store
03/A2/.DS_Store
__MACOSX/03/A2/._.DS_Store
03/A2/build.xml
Some useful functions for working with pipes.
__MACOSX/03/A2/._build.xml
03/A2/src/.DS_Store
__MACOSX/03/A2/src/._.DS_Store
03/A2/src/nz/.DS_Store
__MACOSX/03/A2/src/nz/._.DS_Store
03/A2/src/nz/retro_freedom/.DS_Store
__MACOSX/03/A2/src/nz/retro_freedom/._.DS_Store
03/A2/src/nz/retro_freedom/dsa2016/.DS_Store
__MACOSX/03/A2/src/nz/retro_freedom/dsa2016/._.DS_Store
03/A2/src/nz/retro_freedom/dsa2016/pair/Pair.java03/A2/src/nz/retro_freedom/dsa2016/pair/Pair.javapackage nz.retro_freedom.dsa2016.pair;
import java.util.*;
/**
* @author
* @version 1.0
*
* A data type representing generic, non-{@code null} pairs.
* Pairs cannot be modified once created - if you need to change a pair,
* make a new one instead.
*/
publicclassPair<T1, T2>{
/**
* Makes a new pair.
*
* @param left the left side of the pair (cannot be {@code null}).
* @param right the right side of the pair (cannot be {@code null}).
* @return a new pair with the given left and right sides.
* @throws NullPointerException if left or right are {@code null}.
*/
publicstatic<T1, T2>Pair<T1, T2> make (T1 left, T2 right){
Objects.requireNonNull(left,"left cannot be null.");
Objects.requireNonNull(right,"right cannot be null.");
returnnewPair<T1, T2>(left, right);
}
/**
* Convenience factory for replacing left side of an existing pair.
*
* @param p a pair (cannot be {@code null}).
* @param left a new left element (cannot be {@code null}).
* @return a new pair which is the same as p, but with a new left element.
* @throws NullPointerException if an argument is {@code null}.
*/
publicstatic<T1, T2>Pair<T1, T2> newLeft (Pair<T1, T2> p, T1 left){
Objects.requireNonNull (p,"p cannot be null.");
return make (left, p.right ());
}
/**
* Convenience factory for replacing right side of an existing pair.
*
* @param p a pair (cannot be {@code null}).
* @param right a new right element (cannot be {@code null}).
* @return a new pair which is the same as p, but with a new right element.
* @throws NullPointerException if an argument is {@code null}.
*/
publicstatic<T1, T2>Pair<T1, T2> newRight (Pair<T1, T2> p, T2 right){
Objects.requireNonNull (p,"p cannot be null.");
return make (p.left (), right);
}
/**
* Compares on both elements.
*
* @param o a thing to compare to.
* @return true if both sides of both pairs match.
*/
@Override
publicboolean equals (Object o){
if(o instanceofPair<?,?>){
Pair<?,?> p =(Pair<?,?>)o;
if(left.equals (p.left)&&
right.equals (p.right)){
returntrue;
}
}
returnfalse;
}
/**
* Hashes on both sides.
*
* @return a unique code representing a pair.
*/
@Override
publicint hashCode (){
int result =1;
resu ...
You have been learning about Urie Bronfenbrenner this week- Let's mak.docxdelicecogupdyke
You have been learning about Urie Bronfenbrenner this week. Let's make it real to your life experiences.
Reflect on your own childhood.
1.Identify one microsystem, one mesosystem, one exosystem and your primary macrosystem.
2.Give one example of how each of these impacted your development.
3.Remember an event in your lifetime that had an impact on you. (President Obama's election or Trump's election, events of January 6, fires, birth of a sibling, divorce of parents, pandemic, major storms etc. ) If you need more ideas, you may google "chronosystem". Tell me how that impacted your development.
.
You encounter a flat green organism growing on a rock with no obvious.docxdelicecogupdyke
You encounter a flat green organism growing on a rock with no obvious leaves or stem. Careful examination reveals that it has alternation of generations and the organism you have is haploid. There are very small, multicellular diploid structures growing out of archegonia. This organism also has sporangia and antheridia. Which type of organism is it? liverwort charophyte moss fern
.
More Related Content
Similar to Write the definition of the linkedListKeepLast function- (Please write.docx
package singlylinkedlist; public class Node { public String valu.pdfamazing2001
package singlylinkedlist;
public class Node {
public String value;
public Node next;
public Node(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
}
SingleyLinkedList.java :
package singlylinkedlist;
import java.io.*;
import java.util.*;
/**
* Defines the interface for a singly-linked list.
*
*/
public interface SinglyLinkedList {
/**
* @return Reference to the first node. If the list is empty, this method
* returns null.
*/
public Node getFirst();
/**
* @return Reference to the last node . If the list is empty, this method
* returns null.
*/
public Node getLast();
/**
* @return Number of nodes in the list
*/
public int size();
/**
* @return true if the list has no nodes; false otherwise
*/
public boolean isEmpty();
/**
* Removes all nodes in the list.
*/
public void clear();
/**
* Inserts a new node with the given value after cursor.
*
* @param cursor
* The node to insert after. Set this to null to insert value as
the
* new first Node.
* @param value
* The value to insert
* @return a reference to the newly inserted Node
*/
public Node insert(Node cursor, String value);
/**
* Inserts a new node with the given value at the "end" of the list.
*
* @param value
* @return a reference to the newly inserted Node
*/
public Node append(String value);
/**
* Removes the node after the specified Node (cursor) from the list.
*
* @param cursor
* A reference to the Node to remove.
*/
public void removeAfter(Node cursor);
/**
* Returns a reference to the first Node containing the key, starting from
the
* given Node.
*
* @param start
* @param key
* @return a reference to the first Node containing the key
*/
public Node find(Node start, String key);
/**
* Prints the values of all the items in a list
*/
public void printWholeList();
}
SinglyLinkedTester.java:
package sbccunittest;
import static java.lang.Math.*;
import static java.lang.System.*;
import static org.apache.commons.lang3.StringUtils.*;
import static org.junit.Assert.*;
import static sbcc.Core.*;
import java.io.*;
import java.lang.reflect.*;
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;
import org.apache.commons.lang3.*;
import org.junit.*;
import org.w3c.dom.ranges.*;
import sbcc.*;
import singlylinkedlist.*;
/**
* 09/16/2021
*
* @author sstrenn
*
*/
public class SinglyLinkedListTester {
public static String newline = System.getProperty("line.separator");
public static int totalScore = 0;
public static int extraCredit = 0;
public static boolean isZeroScore = false;
public static String scorePreamble = "";
@BeforeClass
public static void beforeTesting() {
totalScore = 0;
extraCredit = 0;
}
@AfterClass
public static void afterTesting() {
if (isZeroScore) {
totalScore = 0;
extraCredit = 0;
}
println(scorePreamble + "Estimated score (w/o late penalties, etc.) is:
" + totalScore + " out of 25.");
// If the project follows the naming convention, save the results in a
folder on
// the desktop. (Alex Kohanim)
try {
String directory =
substri.
For each task, submit your source java code file.(1) Objective Im.pdfdhavalbl38
For each task, submit your source java code file.
(1) Objective: Implement Link List
Write a class that maintains the scores for a game application. Implement the addition and
removal function to update the database. The gamescore.txt contains player’ name and score data
record fields separated by comma. For Removal function, uses the name field to select record to
remove the game score record.
Download – List.java, LList.java, Dlink.java, GameEntry.java, gamescore.txt
(a)Read gamescore.txt to initialize the Linked list in sorted order. (1 point)
(b)Provide Remove and Add function for user to update the sorted linked list. (1 point)
(2)Add a reverse function to the LList.java class to reverse the order of the linked list. (2 points).
---------------------------------------------------------------------------------------------------------------------
-----------------------------------------
//gamescore.txt
Mike,1105
Rob,750
Paul,720
Anna,660
Rose,590
Jack,510
--------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------
//DLink.java
/** Source code example for \"A Practical Introduction to Data
Structures and Algorithm Analysis, 3rd Edition (Java)\"
by Clifford A. Shaffer
Copyright 2008-2011 by Clifford A. Shaffer
*/
/** Doubly linked list node */
class DLink {
private E element; // Value for this node
private DLink next; // Pointer to next node in list
private DLink prev; // Pointer to previous node
/** Constructors */
DLink(E it, DLink p, DLink n)
{ element = it; prev = p; next = n; }
DLink(DLink p, DLink n) { prev = p; next = n; }
/** Get and set methods for the data members */
DLink next() { return next; }
DLink setNext(DLink nextval)
{ return next = nextval; }
DLink prev() { return prev; }
DLink setPrev(DLink prevval)
{ return prev = prevval; }
E element() { return element; }
E setElement(E it) { return element = it; }
}
--------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------
//GameEntry.java
public class GameEntry {
protected String name;
protected int score;
public GameEntry(String n, int s) {
name = n;
score = s;
}
public String getName() {return name;}
public int getScore() {return score;}
public String toString() {
return \"(\"+name+\",\"+score+\")\";
}
}
--------------------------------------------------------------------------------------------------------------------
----------------------------------
//List.java
/** Source code example for \"A Practical Introduction to Data
Structures and Algorithm Analysis, 3rd Edition (Java)\"
by Clifford A. Shaffer
Copyright 2008-2011 by Clifford A. Shaffer
*/
/** List ADT */
public interface List {
/** Remove all contents from the list, so it is once again
empty. Client is responsible for reclaiming storage
used by the list elements. */
p.
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfmallik3000
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD
OR REMOVE NAME. DO NOT HARD CODE NAME. AGAIN MAKE SURE THE
PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR REMOVE NAME. PLEASE
MAKE SURE THE CODE RUNS WITHOUT ANY ERRORS.
Write a class that maintains the scores for a game application. Implement the addition and
removal function to update the database. The gamescore.txt contains player’ name and score data
record fields separated by comma. For Removal function, uses the name field to select record to
remove the game score record.
Use the List.java, LList.java, Dlink.java, GameEntry.java and gamescore.txt found below
Read gamescore.txt to initialize the Linked list in sorted order by score.
Ask the user to add or remove users to update the sorted linked list.
Display “Name exist” when add an exist name to the list.
Display “Name does not exist” when remove a name not on the list.
List.java File:
/** Source code example for \"A Practical Introduction to Data
Structures and Algorithm Analysis, 3rd Edition (Java)\"
by Clifford A. Shaffer
Copyright 2008-2011 by Clifford A. Shaffer
*/
/** List ADT */
public interface List
{
/**
* Remove all contents from the list, so it is once again empty. Client is
* responsible for reclaiming storage used by the list elements.
*/
public void clear();
/**
* Insert an element at the current location. The client must ensure that
* the list\'s capacity is not exceeded.
*
* @param item
* The element to be inserted.
*/
public void insert(E item);
/**
* Append an element at the end of the list. The client must ensure that
* the list\'s capacity is not exceeded.
*
* @param item
* The element to be appended.
*/
public void append(E item);
/**
* Remove and return the current element.
*
* @return The element that was removed.
*/
public E remove();
/** Set the current position to the start of the list */
public void moveToStart();
/** Set the current position to the end of the list */
public void moveToEnd();
/**
* Move the current position one step left. No change if already at
* beginning.
*/
public void prev();
/**
* Move the current position one step right. No change if already at end.
*/
public void next();
/** @return The number of elements in the list. */
public int length();
/** @return The position of the current element. */
public int currPos();
/**
* Set current position.
*
* @param pos
* The position to make current.
*/
public void moveToPos(int pos);
/** @return The current element. */
public E getValue();
}
LList.java File:
/**
* Source code example for \"A Practical Introduction to Data Structures and
* Algorithm Analysis, 3rd Edition (Java)\" by Clifford A. Shaffer Copyright
* 2008-2011 by Clifford A. Shaffer
*/
// Doubly linked list implementation
class LList implements List
{
private DLink head; // Pointer to list header
private DLink tail; // Pointer to last element in list
protected DLink curr; // Pointer ahead of current element
int cnt; // Size of list
// Constructors
LList(int size)
{
th.
Modify the Simple lexer program given in the link below to .pdfadityaenterprise32
Modify the Simple lexer program given in the link below to:
Add tokens so that all the tokens in the program from Activity 1 of this module are represented (75
points).
The output of your program should specify the type of token in words (Identifier, Keyword ...etc)
not a number (25 points).
Print each token on a separate line.
main.cpp
front.in
(sum + 47) / total
/**
* This the example lexical analyzer code in pages 173 - 177 of the
* textbook,
*
* Sebesta, R. W. (2012). Concepts of Programming Languages.
* Pearson, 10th edition.
*
*/
/* front.c - a lexical analyzer system for simple arithmetic expressions */
#include <stdio.h>
#include <ctype.h>
/* Global declarations */
/* Variables */
int charClass;
char lexeme [100];
char nextChar;
int lexLen;
int nextToken;
FILE *in_fp;
/* Function declarations */
void addChar();
void getChar();
void getNonBlank();
int lex();
/* Character classes */
#define LETTER 0
#define DIGIT 1
#define UNKNOWN 99
/* Token codes */
#define INT_LIT 10
#define IDENT 11
#define ASSIGN_OP 20
#define ADD_OP 21
#define SUB_OP 22
#define MULT_OP 23
#define DIV_OP 24
#define LEFT_PAREN 25
#define RIGHT_PAREN 26
/******************************************************/
/* main driver */
int main()
{
/* Open the input data file and process its contents */
if ((in_fp = fopen("front.in", "r")) == NULL) {
printf("ERROR - cannot open front.in n");
} else {
getChar();
do {
lex();
} while (nextToken != EOF);
}
return 0;
}
/*****************************************************/
/* lookup - a function to lookup operators and parentheses and return the
* token */
int lookup(char ch) {
switch (ch) {
case '(':
addChar();
nextToken = LEFT_PAREN;
break;
case ')':
addChar();
nextToken = RIGHT_PAREN;
break;
case '+':
addChar();
nextToken = ADD_OP;
break;
case '-':
addChar();
nextToken = SUB_OP;
break;
case '*':
addChar();
nextToken = MULT_OP;
break;
case '/':
addChar();
nextToken = DIV_OP;
break;
default:
addChar();
nextToken = EOF;
break;
}
return nextToken;
}
/*****************************************************/
/* addChar - a function to add nextChar to lexeme */
void addChar() {
if (lexLen <= 98) {
lexeme[lexLen++] = nextChar;
lexeme[lexLen] = 0;
} else {
printf("Error - lexeme is too long n");
}
}
/*****************************************************/
/* getChar - a function to get the next character of input and determine its
* character class */
void getChar() {
if ((nextChar = getc(in_fp)) != EOF) {
if (isalpha(nextChar))
charClass = LETTER;
else if (isdigit(nextChar))
charClass = DIGIT;
else charClass = UNKNOWN;
} else {
charClass = EOF;
}
}
/*****************************************************/
/* getNonBlank - a function to call getChar until it returns a non-whitespace
* character */
void getNonBlank() {
while (isspace(nextChar)) getChar();
}
/*****************************************************/
/* lex - a simple lexical analyzer for arithmetic expressions */
int lex() {
lexLen = 0;
getNonBlank();
switch (charClass) {
/* Par.
There are a number of errors in the following program- All errors are.docxclarkjanyce
There are a number of errors in the following program.
All errors are located in main() and structure definitions.
Function declarations and definitions are correct!
Locate all errors, fix them (as shown below), run the program and save its output
as a comment at the end of the source file.
Example:
int num = 10;
int *ptr;
num = &ptr; // <== Error: Comment the line and write the correct line below
// Write a short justification where appropriate
// num = &ptr; // Error #1
ptr = #
Name:
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define DUMMY_TRAILER '\177'
// octal ASCII code of the
// last character in the ASCII table
#define NUM_CITIES 10
typedef struct
{
char name[12];
int temperature[5];
} CITY;
// Stack and Queue Node
typedef struct node NODE;
struct node
{
CITY city;
node *next;
};
// Doubly Linked List Node
typedef struct d_node D_NODE;
struct d_node
{
CITY city;
NODE *forw;
NODE *back;
};
// Stack Functions
NODE *push(NODE *stack, const CITY *pStu);
NODE *pop(NODE **stack);
// Queue Functions
void enqueue(NODE **queue, NODE **rear, const CITY *pStu);
NODE *dequeue(NODE **queue, NODE **rear);
// Doubly Linked List Functions
D_NODE *init_list(void);
int insert(D_NODE *list, const CITY *pStu);
void traverse_forw(D_NODE *list);
void traverse_back(D_NODE *list);
// Other Functions
void printCity(const CITY *pCity);
int main (void)
{
CITY cList[NUM_CITIES] =
{
{"Cupertino", {88, 89, 87, 85, 89}},
{"Flagstaff", {81, 80, 88, 89, 89}},
{"Los Angeles", {87, 88, 89, 89, 90}},
{"Philadelphia", {96, 99, 99, 90, 95}},
{"Phoenix", {106, 109, 109, 100, 105}},
{"Portland", {89, 90, 85, 89, 90}},
{"Reno", {108, 105, 109, 100, 108}},
{"Salem", {85, 90, 85, 89, 90}},
{"Tucson", {107, 100, 109, 100, 108}},
{"Yreka", {101, 109, 100, 108, 109}}
};
NODE *stack = NULL;
NODE *top = NULL;
NODE *queue = NULL, *rear = NULL;
NODE *front;
D_NODE *list;
list = init_list();
// build stack and queue with data from an array of CITY structures
srand((unsigned int)time(NULL));
int count = rand() % 10;
for ( int n = 0; n < count; n++)
{
int i = rand() % NUM_CITIES;
int duplicate = insert(list, &cList[i]);
if(duplicate)
{
// already in the list!
push(stack, &cList[i]);
enqueue(&queue, &rear, cList[i]);
}
}
// display list
printf("\nLIST contents (forwards):\n");
traverse_forw(list);
printf("\nLIST contents (backwards):\n");
traverse_back(list);
// display stack
if (top)
{
printf("\nSTACK contents from top to bottom:\n");
while ((top = pop(stack)))
{
printCity(top->city);
}
}
else
printf ("Empty Stack!\n");
// display queue
if (front)
{
printf("\nQUEUE contents from front to rear:\n");
while ((front = dequeue( queue, rear)))
{
printCity(front->city);
}
}
else
printf ("Empty Queue!\n");
return 0;
}
/***************************************************
Displays the fileds of a CIS_CLASS structure
Pre pCls - a pointer to a CIS_CLASS structure
Post
*/
void printCity(const CITY *pCity)
{
printf("%-20s %3d\n", pCity->name, pCity->temperatur.
C++ Background Circular Linked List A circular linked list.pdfsaradashata
C++
Background:
Circular Linked List: A circular linked list is a linked list where a non-empty list has no null pointers.
Unless empty, each node has a pointer to the next node, and the last node points back to the first
node.
Assigment:
Write a cpp program that will serve the purpose of a test driver for previously written CLinkedList.h
file. Your program will:
1) Create a choice menu and prompt the user for input. Must be case insensitive!
2) Read the input and call for functions outside of main, in order to perform operations chosen by
the user. These functions involve: Inserting Interger, Removing Interger, Forward Print and
Backward Print.
Requirements and Notes:
1. Forwards Print does not require a subfunction in order to produce output. All the other
operations must call corresponding subfunctions.
2. Nodes of the circular list must be arranged in ascending order.
3. User Input must be processed case insensitive, and implemented using the loop.
4. Document your code completely.
5. CLinkedList.h file contains 3 classes.
- Circular linked lists class with following member functions: constructor, copy constructor,
destructor, assignment operator, insert and remove.
- Node class included in the file header.
- A list iterator class provides a public interface to the list. The pointer points at nodes in the linked
list. Its member functions are as follows:
Constructor: Assigns the linked list data member to the parameter, a reference to a circular linked
list.
begin() sets the iterator to the first node of the linked list (or NULL if the list is empty)
isEmpty() returns whether or not the wrapped linked list is empty
isFirstNode() returns whether the present node is the first node of the linked list
isLastNode() returns whether the present node is the last node of the linked list
operator*() returns the data of the node currently pointed at. (You need 2)
operator++() pre-increment operator advances the pointer to the next node in the list, if there is
one
operator++(int) post-increment operator advances the pointer to the next node in the list, if there
is one
6. Insert function must give feedback where it says the position of where the int was inserted for
example: "Inserting 25 in the middle."
7. Remove function must give either one of these types of feedback:
- "Removing 25" if the int given by the user was found in the list
-"Cannot find 25" if it was not. The program will then move the user back to the choice menu.
Files:
// File: Node.h
// Singly-linked list node definition/implementation (also good for circular)
#ifndef NODE_H
#define NODE_H
// Need to prototype template classes if they are to be friends
template <typename eltType> class CLinkedList;
template <typename eltType> class CListItr;
template <typename eltType> class Node
{ private:
Node(eltType info, Node* link = NULL ) :
data(info), next(link)
{};
eltType data;
Node *next;
friend class CLinkedList<eltType>;
friend class CListItr<eltType>;
};
#endif
// File: CLinkedList.h
.
Background Circular Linked List A circular linked list is .pdfaaseletronics2013
Background:
Circular Linked List: A circular linked list is a linked list where a non-empty list has no null pointers.
Unless empty, each node has a pointer to the next node, and the last node points back to the first
node.
Assigment:
Write a cpp program that will serve the purpose of a test driver for previously written CLinkedList.h
file. Your program will:
1) Create a choice menu and prompt the user for input. Must be case insensitive!
2) Read the input and call for functions outside of main, in order to perform operations chosen by
the user. These functions involve: Inserting Interger, Removing Interger, Forward Print and
Backward Print.
Requirements and Notes:
1. Forwards Print does not require a subfunction in order to produce output. All the other
operations must call corresponding subfunctions.
2. Nodes of the circular list must be arranged in ascending order.
3. User Input must be processed case insensitive, and implemented using the loop.
4. Document your code completely.
5. CLinkedList.h file contains 3 classes.
- Circular linked lists class with following member functions: constructor, copy constructor,
destructor, assignment operator, insert and remove.
- Node class included in the file header.
- A list iterator class provides a public interface to the list. The pointer points at nodes in the linked
list. Its member functions are as follows:
Constructor: Assigns the linked list data member to the parameter, a reference to a circular linked
list.
begin() sets the iterator to the first node of the linked list (or NULL if the list is empty)
isEmpty() returns whether or not the wrapped linked list is empty
isFirstNode() returns whether the present node is the first node of the linked list
isLastNode() returns whether the present node is the last node of the linked list
operator*() returns the data of the node currently pointed at. (You need 2)
operator++() pre-increment operator advances the pointer to the next node in the list, if there is
one
operator++(int) post-increment operator advances the pointer to the next node in the list, if there
is one
6. Insert function must give feedback where it says the position of where the int was inserted for
example: "Inserting 25 in the middle."
7. Remove function must give either one of these types of feedback:
- "Removing 25" if the int given by the user was found in the list
-"Cannot find 25" if it was not. The program will then move the user back to the choice menu.
Files:
// File: Node.h
// Singly-linked list node definition/implementation (also good for circular)
#ifndef NODE_H
#define NODE_H
// Need to prototype template classes if they are to be friends
template <typename eltType> class CLinkedList;
template <typename eltType> class CListItr;
template <typename eltType> class Node
{ private:
Node(eltType info, Node* link = NULL ) :
data(info), next(link)
{};
eltType data;
Node *next;
friend class CLinkedList<eltType>;
friend class CListItr<eltType>;
};
#endif
// File: CLinkedList.h
// C.
write recursive function that calculates and returns the length of a.pdfarpitcomputronics
write recursive function that calculates and returns the length of a linked list
Solution
// C code to determine length of linked list recursively
#include
#include
// node of linked list
struct node
{
int key;
struct node* next;
};
// push key to linked list
void push(struct node** root, int new_element)
{
struct node* nodeNew = (struct node*) malloc(sizeof(struct node));
nodeNew->key = new_element;
nodeNew->next = (*root);
(*root) = nodeNew;
}
// recursively get length of linked list
int lengthLinkedlist(struct node* root)
{
// base case
if (root == NULL)
return 0;
// recursively call the function
return 1 + lengthLinkedlist(root->next);
}
int main()
{
struct node* root = NULL;
push(&root, 11);
push(&root, 34);
push(&root, 4);
push(&root, 23);
push(&root, 14);
push(&root, 88);
push(&root, 56);
push(&root, 84);
push(&root, 6);
/* Check the count function */
printf(\"Length of Linked list: %d\ \", lengthLinkedlist(root));
return 0;
}
/*
output:
Length of Linked list: 9
*/.
Please code in C language- Please do part 1 and 2- Do not recycle answ.docxcgraciela1
Please code in C language. Please do part 1 and 2. Do not recycle answers and implement the starter code
Starter code:
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "linkedlist.h"
// print an error message by an error number, and return
// the function does not exit from the program
// the function does not return a value
void error_message(enum ErrorNumber errno) {
char *messages[] = {
"OK",
"Memory allocaton failed.",
"Deleting a node is not supported.",
"The number is not on the list.",
"Sorting is not supported.",
"Reversing is not supported.",
"Token is too long.",
"A number should be specified after character d, a, or p.",
"Token is not recognized.",
"Invalid error number."};
if (errno < 0 || errno > ERR_END)
errno = ERR_END;
printf("linkedlist: %s\n", messages[errno]);
}
node *new_node(int v) {
node *p = malloc(sizeof(node)); // Allocate memory
if (p == NULL) {
error_message(ERR_NOMEM);
exit(-1);
}
// Set the value in the node.
p->v = v; // you could do (*p).v
p->next = NULL;
return p; // return
}
node *prepend(node *head, node *newnode) {
newnode->next = head;
return newnode;
}
node *find_node(node *head, int v) {
while (head != NULL) {
if (head->v == v)
return head;
head = head->next;
}
return head;
}
node *find_last(node *head) {
if (head != NULL) {
while (head->next != NULL)
head = head->next;
}
return head;
}
node *append(node *head, node *newnode) {
node *p = find_last(head);
newnode->next = NULL;
if (p == NULL)
return newnode;
p->next = newnode;
return head;
}
node *delete_list(node *head) {
while (head != NULL) {
node *p = head->next;
free(head);
head = p;
}
return head;
}
void print_list(node *head) {
printf("[");
while (head) {
printf("%d, ", head->v);
head = head->next;
}
printf("]\n");
}
void print_node(node *p) {
printf("%p: v=%-5d next=%p\n", p, p->v, p->next);
}
void print_list_details(node *head) {
while (head) {
print_node(head);
head = head->next;
}
}
// functions that have not been implemented
node *delete_node(node *head, int v) {
// TODO
error_message(ERR_NODELETE);
return head;
}
/*
* Given a pointer to the head node of an acyclic list, change the
* next links such that the nodes are linked in reverse order.
* Allocating new nodes or copying values from one node to another
* is not allowed, but you may use additional pointer variables.
* Return value is a pointer to the new head node.
*/
node *reverse_list(node *head) {
// TODO
error_message(ERR_NOREVERSE);
return head;
}
Part 1. Delete node. The linked list example we have studied in lecture maintains a singly linked list of integers. The program can append and prepend integers to the list. Type help in the program to see a list of commands. Note that if the number to be added is already on the list, the program prints the information about the node that stores the number and does not add the number twice. The list is displayed every time an integer is processed. Currently, the program does not support the delete function..
1- The design of a singly-linked list below is a picture of the functi (1).pdfafgt2012
1. The design of a singly-linked list
below is a picture of the function that needs to be used
below is the code of the above picture:
#include <string>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define defaultSize 100
void Assert(bool val, string s)
{
if (!val)
{ // Assertion failed -- close the program
cout << "Assertion Failed: " << s << endl;
exit(-1);
}
}
template <typename E>
class Link {
public:
E element; // Value for this node
Link *next; // Pointer to next node in list
// Constructors
Link(const E& elemval, Link<E>* nextval = NULL)
{ element = elemval; next = nextval; }
Link(Link<E>* nextval =NULL) { next = nextval; }
};
template <typename E>
class LList: public Link<E> {
private:
Link<E>* head;// Intialization helper method
Link<E>* tail;// Pointer to last element
Link<E>* curr;// Access to current element
int cnt;// Size of list
void init(){// Intialization helper method
curr = tail = head = new Link<E>;
cnt = 0;
}
void removeall() {// Return link nodes to free store
while(head != NULL) {
curr = head;
head = head->next;
delete curr;
}
}
public:
LList(int size=defaultSize) { init(); }// Constructor
~LList() { removeall(); }// Destructor
void print() const;// Print list contents
void clear() { removeall(); init(); }// Clear list
// Insert "it" at current position
void insert(const E& it) {
curr->next = new Link<E>(it, curr->next);
if (tail == curr) tail = curr->next; // New tail
cnt++;
}
void append(const E& it) { // Append "it" to list
tail = tail->next = new Link<E>(it, NULL);
cnt++;
}
// Remove and return current element
E remove() {
Assert(curr->next != NULL, "No element");
E it = curr->next->element; // Remember value
Link<E>* ltemp = curr->next; // Remember link node
if (tail == curr->next) tail = curr; // Reset tail
curr->next = curr->next->next; // Remove from list
delete ltemp; // Reclaim space
cnt--; // Decrement the count
return it;
}
void moveToStart()// Place curr at list start
{ curr = head; }
void moveToEnd() // Place curr at list end
{ curr = tail; }
void prev(){
if (curr == head) return;
Link<E>* temp = head;
while (temp->next!=curr) temp=temp->next;
curr = temp;
}
void next(){ if (curr != tail) curr = curr->next; }
int length() const { return cnt; }
int currPos() const {
Link<E>* temp = head;
int i;
for (i=0; curr != temp; i++)
temp = temp->next;
return i;
}
void moveToPos(int pos){
Assert ((pos>=0)&&(pos<=cnt), "Position out of range");
curr = head;
for(int i=0; i<pos; i++) curr = curr->next;
}
const E& getValue() const {
Assert(curr->next != NULL, "No value");
return curr->next->element;
}
};
completed this code to fulfill the requirement below:
Write a function to insert an integer into a singly-linked list of elements arranged from largest to
smallest. Requires that elements remain ordered after insertion.
2. The design of array-based stack
below is a picture of the function that needs to be used
below is the code of the above picture:
#include <string.h>
#.
03/.DS_Store
__MACOSX/03/._.DS_Store
03/A2/.DS_Store
__MACOSX/03/A2/._.DS_Store
03/A2/build.xml
Some useful functions for working with pipes.
__MACOSX/03/A2/._build.xml
03/A2/src/.DS_Store
__MACOSX/03/A2/src/._.DS_Store
03/A2/src/nz/.DS_Store
__MACOSX/03/A2/src/nz/._.DS_Store
03/A2/src/nz/retro_freedom/.DS_Store
__MACOSX/03/A2/src/nz/retro_freedom/._.DS_Store
03/A2/src/nz/retro_freedom/dsa2016/.DS_Store
__MACOSX/03/A2/src/nz/retro_freedom/dsa2016/._.DS_Store
03/A2/src/nz/retro_freedom/dsa2016/pair/Pair.java03/A2/src/nz/retro_freedom/dsa2016/pair/Pair.javapackage nz.retro_freedom.dsa2016.pair;
import java.util.*;
/**
* @author
* @version 1.0
*
* A data type representing generic, non-{@code null} pairs.
* Pairs cannot be modified once created - if you need to change a pair,
* make a new one instead.
*/
publicclassPair<T1, T2>{
/**
* Makes a new pair.
*
* @param left the left side of the pair (cannot be {@code null}).
* @param right the right side of the pair (cannot be {@code null}).
* @return a new pair with the given left and right sides.
* @throws NullPointerException if left or right are {@code null}.
*/
publicstatic<T1, T2>Pair<T1, T2> make (T1 left, T2 right){
Objects.requireNonNull(left,"left cannot be null.");
Objects.requireNonNull(right,"right cannot be null.");
returnnewPair<T1, T2>(left, right);
}
/**
* Convenience factory for replacing left side of an existing pair.
*
* @param p a pair (cannot be {@code null}).
* @param left a new left element (cannot be {@code null}).
* @return a new pair which is the same as p, but with a new left element.
* @throws NullPointerException if an argument is {@code null}.
*/
publicstatic<T1, T2>Pair<T1, T2> newLeft (Pair<T1, T2> p, T1 left){
Objects.requireNonNull (p,"p cannot be null.");
return make (left, p.right ());
}
/**
* Convenience factory for replacing right side of an existing pair.
*
* @param p a pair (cannot be {@code null}).
* @param right a new right element (cannot be {@code null}).
* @return a new pair which is the same as p, but with a new right element.
* @throws NullPointerException if an argument is {@code null}.
*/
publicstatic<T1, T2>Pair<T1, T2> newRight (Pair<T1, T2> p, T2 right){
Objects.requireNonNull (p,"p cannot be null.");
return make (p.left (), right);
}
/**
* Compares on both elements.
*
* @param o a thing to compare to.
* @return true if both sides of both pairs match.
*/
@Override
publicboolean equals (Object o){
if(o instanceofPair<?,?>){
Pair<?,?> p =(Pair<?,?>)o;
if(left.equals (p.left)&&
right.equals (p.right)){
returntrue;
}
}
returnfalse;
}
/**
* Hashes on both sides.
*
* @return a unique code representing a pair.
*/
@Override
publicint hashCode (){
int result =1;
resu ...
Similar to Write the definition of the linkedListKeepLast function- (Please write.docx (20)
You have been learning about Urie Bronfenbrenner this week- Let's mak.docxdelicecogupdyke
You have been learning about Urie Bronfenbrenner this week. Let's make it real to your life experiences.
Reflect on your own childhood.
1.Identify one microsystem, one mesosystem, one exosystem and your primary macrosystem.
2.Give one example of how each of these impacted your development.
3.Remember an event in your lifetime that had an impact on you. (President Obama's election or Trump's election, events of January 6, fires, birth of a sibling, divorce of parents, pandemic, major storms etc. ) If you need more ideas, you may google "chronosystem". Tell me how that impacted your development.
.
You encounter a flat green organism growing on a rock with no obvious.docxdelicecogupdyke
You encounter a flat green organism growing on a rock with no obvious leaves or stem. Careful examination reveals that it has alternation of generations and the organism you have is haploid. There are very small, multicellular diploid structures growing out of archegonia. This organism also has sporangia and antheridia. Which type of organism is it? liverwort charophyte moss fern
.
You are the PR specialist for St- John's Ambulance- The organization w.docxdelicecogupdyke
You are the PR specialist for St. John's Ambulance. The organization would like to raise awareness about the need for donations and volunteers to support their Opioid Poisoning Response Training it offers in the Kitchener-Waterloo Region.
.
You are the CFO of a large academic medical center and your organizati (1).docxdelicecogupdyke
You are the CFO of a large academic medical center and your organization is in the process of implementing a new electronic health record (EHR) and practice management (PM) system. Several of your providers are complaining about conversion to the new EHR and PM system and are being resistant to change. Review "Perspective 13.5: Financial Benefits From IT," PRESENTED BELLOW
-Utilize professional research to analyze opportunities for your organization based on potential profits and risks. Include a discussion on improved quality of care that may be realized.
PERSPECTIVE 13.5 FINANCIAL BENEFITS FROM IT Investment in IT is considered a driving factor in improving patient care; the critical question asked by CEOs, CFOs, and board members is whether hospitals achieve a financial return from their IT investments. The inability to measure and account for financial benefits from IT investments has led some hospital administrators to avoid making these types of capital investments that can provide more efficient, higher-quality care and also improve patient and provider satisfaction. One health care system that decided to make this investment is Banner Health, which implemented an IT system at its newest hospital, Banner Estrella Medical Center in Phoenix, Arizona. By investing in IT and receiving input from physicians, pharmacists, nurses, informaticists, and other clinicians, the hospital was able to design new work flows and establish evidence-based order sets. The improved IT design and standard order sets were implemented across departmental functions such as care management, clinical documentation, computerized provider order entry (CPOE), nursing order management, and medication administration and scheduling, and also across processes in departments such as health information management, emergency services, obstetrics, pediatrics, pharmacy, and surgery. This IT investment resulted in a $2.6 million cost savings from greater retention of nurses, which lowered the costs of recruiting, hiring, and training new nurses, and from reducing accounts receivable billing by one day, which resulted in faster payment; decreasing the incidence of adverse drug events, length of stay, and pharmacy costs; decreasing overtime expenses for nurses as a result of improving their efficiency in charting and shifting tasks; and reducing forms costs because information was digitized.
.
You are on a field trip with your bio class- Your water sample from a.docxdelicecogupdyke
You are on a field trip with your bio class. Your water sample from a pond contains many small green cells that swim using flagellae. You ask your professor what they are. Your professor, who can be annoying at times, tells you that they are members of the Excavata and that the green color comes from chlorophyll and then asks you what they are. What are they? Diatoms Euglena Giardia Dinoflagellates Clear my selection
.
You are fortunate to travel to a tropical forest- You find an insect o.docxdelicecogupdyke
You are fortunate to travel to a tropical forest. You find an insect on the porch of your cabin. Is this insect likely to officially listed as an endangered or threatened species? Why of why not? No it is not likely because most insects are abundant. Yes it is likely because it occurs in the tropics in a threatened habitat. No it is not likely, because there is very little data on most insect species. Yes it is likely because most organisms are now under threat Clear my selection
.
You are a Government employee working in the Human Resources departmen.docxdelicecogupdyke
You are a Government employee working in the Human Resources department. Your supervisor has asked you to create a new form for new job applicants. Create the form using the knowledge you have gained about forms creation. Ensure layout and format is done according to standard. The information that needs to be collected on the form includes: Name and Address Social Insurance Contact Information Job Type Availability Past employment with Government Former convictions Drivers License Information Past accidents/moving violations Employment History Education
.
You are a genetic cownselar- A single mother cnmes to vou- where both.docxdelicecogupdyke
You are a genetic cownselar. A single mother cnmes to vou, where both of her dinghters have a shis divorder, but skin and tuei Mom do net. hays. this diserder. What can vou absolutely, definitely conclude, without ary hesitation or second thoughts? the gene is x -Hinhed recessive the gene is autosomal recessive the gene is autosomat dominant the gene is X-linked dominant No defirite conclusions can be made with this limited information
.
Write the following report that can be a powerpoint presentation-The g.docxdelicecogupdyke
Write the following report that can be a powerpoint presentation:
The government of St. Kitts and Nevis are looking create cybersecurity laws for the country.
Find the following:
What is Cybercrimes?
Different types of Cybercrimes and how dangerous they are?
Laws and regulations for cybercrime including relevant punishments.
How these laws and reguations can protect a country. And why is it important to have cybercrimes.
How cybercrimes have advance over the years.
Social Media (ex. how Russia used Facebook as a weapon against the US)
How we can use Social Media responsible.
Laws and regulations against the distrubtion and sharing of confidential information like pictures and videos.
How government can work with the private sector and to secure the country and at what cost.
Try and make it into a slides for powerpoint presentation.
Thank you.
The government of St. Kitts and Nevis are looking create cybersecurity laws for the country.
Find the following:
What is Cybercrimes?
Different types of Cybercrimes and how dangerous they are?
Laws and regulations for cybercrime including relevant punishments.
How these laws and reguations can protect a country. And why is it important to have cybercrimes.
How cybercrimes have advance over the years.
Social Media (ex. how Russia used Facebook as a weapon against the US)
How we can use Social Media responsible.
Laws and regulations against the distrubtion and sharing of confidential information like pictures and videos.
How government can work with the private sector and to secure the country and at what cost.
Try and make it into a slides for powerpoint presentation.
Thank you.
.
Write two functions using the Front and Back Linear Search algorithms-.docxdelicecogupdyke
Write two functions using the Front and Back Linear Search algorithms. (USE C++)
Function #1. Find if a search key is in the list. Once the search key is found, return the element's position in the list.
Function #2. Find if a search key is in the list. If found, print out all of the positions of the occurrences. Otherwise, print out that the search key is not found.
.
xpected to grow geometrically- (Assume that interactions ith other spe.docxdelicecogupdyke
xpected to grow geometrically? (Assume that interactions ith other species can be ignored.) A large population of finches that breeds once a year and lives on an island with limited food A small population of finches that breeds once a year and lives on an island with abundant food A small population of finches that breeds continuously and lives on an island with abundant food A small population of finches that breeds continuously and lives on an island with limited food
.
Write the pseudocode for Python for the following- from Celsius to Fah.docxdelicecogupdyke
Write the pseudocode for Python for the following:
from Celsius to Fahrenheit and Kelvins [20 points]
from Fahrenheit to Celsius and Kelvins [20 points]
from Kelvins to Celsius and Fahrenheit [20 points]
You must use the IF, ELSE, ELIF statements or a combination of these statements. [10 points]
You must use functions [at least three functions] [20 points]
You must have error trapping routine(s) [10 points]
.
Write SQL commands that convert the Database schema to Tables with the.docxdelicecogupdyke
Write SQL commands that convert the Database schema to Tables with the need to build the necessary Constraints such as Primary key, Foreign key, Unique, not null, check constraints and enter no less than three records in each table and deliver the necessary code to implement the above and upload a screenshot to implement those commands
.
write the adjusting entries for following Given Data-.docxdelicecogupdyke
write the adjusting entries for following
Given Data:
MAGLIOCHETTI MOVING CORP.
Statement of Earnings Statement of Financial Position
For the Period Ended December 31, 2020
At December 31, 2020
Transportation revenue$90,000
Expenses:
Salaries expense15,000
Maintenance expense14,000
Other expenses20,000
Total expenses$49,000
Net earnings$41,000
ASSETS
cash 2000
receivables 3000
inventory of maintenances supplies 5000
equipment 45000
prepaid expenses 5000
other assets 25000
total assets 85000
Total assets $85,000
Liabilities
Accounts payable $9,000
Shareholders' Equity
Contributed capital (10,000 shares outstanding) 35,000
Retained earnings 41,000
Total liabilities and shareholders' equity $85,000
Additional information:
Number of shares 10000
(a)Maintenance supplies on hand, December 31, 2020 $3,000
(b)Prepaid insurance at December 31, 2020 $2,500
(Total insurance premium paid in 2020 was debited to Prepaid Insurance)
(c)Cost of equipment purchased on January 1, 2020 $45,000
Unrecorded depreciation expense for 2020 $9,000
(d)Unpaid (and unrecorded) salaries at December 31, 2020 $1,500
(e)At December 31, 2020, transportation revenue collected in advance (credited to Transportation Revenue when cash was received) $5,000
(f)Income tax rate
30%
adjusting entries
.
Write python code to collect 1000 posts from Twitter- or Facebook- or.docxdelicecogupdyke
Write python code to collect 1000 posts from Twitter, or Facebook, or Instagram. You can either use hashtags, keywords, user_name, user_id, or other information to collect the data.
The following information needs to be collected:
(1) User_name
(2) Posted time
(3) Text
.
write one to two paragraphs on the significance about Jati Explain how.docxdelicecogupdyke
write one to two paragraphs on the significance about Jati
Explain how the item is a cause or a consequence of some event.
Explain how the item exemplified some trend or movement or ideology.
Explain how the item ties into one of our class themes.
Explain any other way this item is significant
.
Write in C++ Calculate the mean of a vector of floating point numbers.docxdelicecogupdyke
Write in C++
Calculate the mean of a vector of floating point numbers **/ float mean(vector\& values) Calculate the standard deviation from a vector of floating point numbers + / float standard deviation(vector\& values) Main **/ int main() I Prompt the user and get the number of values to enter + Get the values from the user + /* Display the mean and standard deviation return 0;
.
Write down the code that will count the number of clicks for a LIKE bu.docxdelicecogupdyke
Write down the code that will count the number of clicks for a LIKE button. You need to write this code with both objects Local \& Session. Discuss the difference between these two Objects. Hint: Name/value pairs are always stored as striags. Remember to convert them to another format when needed! Number(localStorageclickcount)
.
Write declarations for variables p1 and p2 whose values will be addres.docxdelicecogupdyke
Write declarations for variables p1 and p2 whose values will be addresses of memory locations in which a double can be stored. Write a statement to assign the address of integer i2 to the variable p2,
.
Write an example of an organization which has formed an inter-organiza.docxdelicecogupdyke
Write an example of an organization which has formed an inter-organizational relationship and collaborated with another competitor organization because of changes in the external environment.
1. Describe and evaluate the changes in the external environment and their impact on the organization.
2. What type and scope of inter-organizational collaborative relationship was formed by the company and why?
.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
Write the definition of the linkedListKeepLast function- (Please write.docx
1. Write the definition of the linkedListKeepLast function. (Please write the following in C,
Thank you)
The purpose of the function is to create a new linked list containing
the last node in each linked list in the hash table beginning with the first linked list.
The rest of the nodes are to be displayed to the screen, then returned to the heap.
Example:
If the user enters the following keys:
201, 102, 233, 567, 456, 654, 465, 645, quit
list at index 0 is empty
list at index 1 is not empty:
201
102
567
list at index 2 is not empty:
233
list at index 3 is empty
list at index 4 is not empty:
456
654
465
645
Deleted nodes:
--> at index 0:
--> at index 1: 201 102
2. --> at index 2:
--> at index 3:
--> at index 4: 456 654 465
The final linked list contains:
567
233
645
Written by:
*/
#include <stdio.h>
#include <stdlib.h> // malloc(), free(), exit()
#include <string.h>
#define NUMPOINTERS 5
typedef struct node STUDENTREC;
struct node
{
char id[10];
struct node *next;
};
// Function Declarations
int hash(char id[]);
STUDENTREC *insert(char id[],
STUDENTREC *student_body[],
3. int hashval);
void traverse(STUDENTREC *student_body[]);
void displayLL(STUDENTREC *list, char *description);
STUDENTREC *linkedListKeepLast(STUDENTREC *student_body[]);
int main (void)
{
STUDENTREC *student_body[NUMPOINTERS] = {NULL};
STUDENTREC *person;
STUDENTREC *endList;
char id[10];
int hashval;
printf(" ~*~ Hashing using collision resolution by chaining ~*~n");
printf("t Enter Student ID (or quit): ");
scanf("%s", id);
while(strcmp(id, "quit"))
{
hashval = hash(id);
person = insert(id, student_body, hashval);
if (person) // not NULL => duplicate
{
printf("Duplicate record!n");
}
printf("t Enter Student ID (or quit): ");
4. scanf("%s", id);
}
traverse(student_body);
endList = linkedListKeepLast(student_body);
displayLL(endList, "New List");
traverse(student_body);
return 0;
}
/*
The purpose of the function is to create a new linked list containing
the last node in each linked list in the hash table beginning with the first linked list.
The rest of the nodes are to be displayed to the screen, then returned to the heap.
*/
STUDENTREC *linkedListKeepLast(STUDENTREC *student_body[])
{
STUDENTREC *newList = NULL;
/* *********************************************************
Write your code here
Get the job done without calling other linked list functions
********************************************************* */
return newList;
}
/***************************************************
5. Hash Student ID by summing the cubes
of the ASCII value of characters and then take
the modulo of this sum.
*/
int hash(char id[])
{
long sum = 0;
while (*id) // != '0'
{
sum += *id * *id * *id;
id++;
}
return sum % NUMPOINTERS;
}
/***************************************************
Insert a new Social Security number into the
array of student records, at index equal to
hashvalue
*/
STUDENTREC *insert(char id[],
STUDENTREC *student_body[],
int hashval)
{
6. STUDENTREC **mover; // Use ** to write elegant code
mover = &student_body[hashval];
while (*mover)
{
if (strcmp(id,(*mover)->id) == 0) return *mover;
mover = &((*mover)->next);
}
if ((*mover = (STUDENTREC *) malloc(sizeof(STUDENTREC))) == NULL)
{
printf("Malloc error in insert!n");
exit(1);
}
strcpy((*mover)->id, id);
(*mover)->next = NULL; // set the link of the new node to NULL
printf("%s has been placed in the list at location %d.n", (*mover)->id, hashval);
return NULL;
}
/***************************************************
Traversing the lists in a hash table
*/
void traverse(STUDENTREC *student_body[])
{
int i;
7. // STUDENTREC **mover; // Use ** for fun and practice
// not needed for traverse
for (i = 0; i < NUMPOINTERS; i++)
{
printf("Contents of list %2dn", i);
printf("--------------------n");
// for (mover = &student_body[i]; *mover; mover = &(*mover)->next)
// { // &((*mover)->next)
// printf("%sn", (*mover)->ss);
// }
displayLL(student_body[i], NULL);
printf("n");
}
}
/***************************************************
Traversing a linked list
*/
void displayLL(STUDENTREC *list, char *description)
{
if (list) // != NULL
{
if (description) // != NULL
{
8. printf ("%sn", description);
printf("--------------------n");
}
STUDENTREC **mover; // Use ** for fun and practice
// not needed for traverse
for (mover = &list; *mover; mover = &(*mover)->next)
{ // &((*mover)->next)
printf("%sn", (*mover)->id);
}
}
else
printf ("Empty!");
printf("n");
}
/*
~*~ Hashing using collision resolution by chaining ~*~
Enter Student ID (or quit): 201
201 has been placed in the list at location 1.
Enter Student ID (or quit): 102
102 has been placed in the list at location 1.
Enter Student ID (or quit): 233
233 has been placed in the list at location 2.
Enter Student ID (or quit): 567
9. 567 has been placed in the list at location 1.
Enter Student ID (or quit): 456
456 has been placed in the list at location 4.
Enter Student ID (or quit): 654
654 has been placed in the list at location 4.
Enter Student ID (or quit): 465
465 has been placed in the list at location 4.
Enter Student ID (or quit): 645
645 has been placed in the list at location 4.
Enter Student ID (or quit): quit
Contents of list 0
--------------------
Empty!
Contents of list 1
--------------------
201
102
567
Contents of list 2
--------------------
233
Contents of list 3
--------------------
10. Empty!
Contents of list 4
--------------------
456
654
465
645
Deleted nodes:
--> at index 0:
--> at index 1: 201 102
--> at index 2:
--> at index 3:
--> at index 4: 456 654 465
New List
--------------------
567
233
645
Contents of list 0
--------------------
Empty!
Contents of list 1
--------------------
11. Empty!
Contents of list 2
--------------------
Empty!
Contents of list 3
--------------------
Empty!
Contents of list 4
--------------------
Empty!
*/