Using c++ , screenshot of display output as well. Preferably using visual studio. The output is Random I believe doesn’t have to be the same,
Attached is the input a & b txt file as well.
Remove duplicates in c++
#include<bits/stdc++.h>
using namespace std;
struct Node
{
int data;
struct Node *next;
};
struct Node *newNode(int data)
{
Node *temp = new Node;
temp->data = data;
temp->next = NULL;
return temp;
}
void removeDuplicates(struct Node *start)
{
struct Node *ptr1, *ptr2, *dup;
ptr1 = start;
while (ptr1 != NULL && ptr1->next != NULL)
{
ptr2 = ptr1;
while (ptr2->next != NULL)
{
if (ptr1->data == ptr2->next->data)
{
dup = ptr2->next;
ptr2->next = ptr2->next->next;
delete(dup);
}
else
ptr2 = ptr2->next;
}
ptr1 = ptr1->next;
}
}
void printList(struct Node *node)
{
while (node != NULL)
{
printf("%d ", node->data);
node = node->next;
}
}
int main()
{
struct Node *start = newNode(10);
start->next = newNode(12);
start->next->next = newNode(11);
start->next->next->next = newNode(11);
start->next->next->next->next = newNode(12);
start->next->next->next->next->next =
newNode(11);
start->next->next->next->next->next->next =
newNode(10);
printf("Linked list before removing duplicates ");
printList(start);
removeDuplicates(start);
printf("\nLinked list after removing duplicates ");
printList(start);
return 0;
}
Intersection set of two linked list in c++
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
struct Node
{
int data;
struct Node* next;
};
void push(struct Node** head_ref, int new_data);
bool isPresent(struct Node *head, int data);
struct Node *getIntersection(struct Node *head1,
struct Node *head2)
{
struct Node *result = NULL;
struct Node *t1 = head1;
while (t1 != NULL)
{
if (isPresent(head2, t1->data))
push (&result, t1->data);
t1 = t1->next;
}
return result;
}
void push (struct Node** head_ref, int new_data)
{
struct Node* new_node =
(struct Node*) malloc(sizeof(struct Node));
new_node->data = new_data;
new_node->next = (*head_ref);
(*head_ref) = new_node;
}
void printList (struct Node *node)
{
while (node != NULL)
{
printf ("%d ", node->data);
node = node->next;
}
}
bool isPresent (struct Node *head, int data)
{
struct Node *t = head;
while (t != NULL)
{
if (t->data == data)
return 1;
t = t->next;
}
return 0;
}
int main()
{
struct Node* head1 = NULL;
struct Node* head2 = NULL;
struct Node* intersecn = NULL;
struct Node* unin = NULL;
push (&head1, 20);
push (&head1, 4);
push (&head1, 15);
push (&head1, 10);
push (&head2, 10);
push (&head2, 2);
push (&head2, 4);
push (&head2, 8);
intersecn = getIntersection (head1, head2);
printf ("\n First list is \n");
printList (head1);
printf ("\n Second list is \n");
printList (head2);
printf ("\n Intersection list is \n");
printList (intersecn);
return 0;
}
Note : copy the cpp files and run on complier you will find
output
Using c++ , screenshot of display output as well. Preferably using visual studio. The output is...
Please answer this problem in C++, Thank you! Read and study the sample program: "hashing with chaining using singly linked lists", as well as "hashing with chaining using doubly linked lists". Notice this program is complete except it doesn't include the remove function. Write the remove function and test it with the rest of the program including the given main program. Upload your C++ source file. ---Here is the referenced program: "hashing with chaining using singly linked lists". Below this...
use visual studio, this is the step how to creat the
project.
creat new project in the next page make sure to select visual
C++ then empty project on the next dialog box. after you create new
project click on add new item and then select C++ source file (cpp
file) and click add.
after you finish, make sure you send me the run file ( result)
as well
Write a program that calculates and prints the amount of wages...
NB: All C programs should be compiled using C Compiler application. The code should be shown on the document. A screen shot of the running program given as output on the assignment. a). Describe the types of arrays and operations that can be performed of them. [10] b). Write a program to print the multiplication table from 1*1 to 12*10. [10] Example MULTIPLICATION TABLE 1 2 3 4 5 6 7 8 9 10 2 4 6 8 10 12...
Lab #2 Address Book Unsorted List (C++) Using classes, design an online address book to keep track of the names (first and last), addresses, phone numbers, and dates of birth. The menu driven program should perform the following operations: Load the data into the address book from a file Write the data in the address book to a file Search for a person by last name or phone number (one function to do both) Add a new entry to the...
Programming Project #5 – Binary Tree
Exercise 19 on page 637 of the text a through f
Here is the array to build the initial binary tree:
int [] data = { 50, 30, 60, 10, 80, 55, 40 };
BUT, make sure the code works with any binary tree created from
an array named data
In addition to the main .java file, make sure you also
create a Node.java and a Tree.java file that contain the code that
allows...
Write a Java program, In this project, you are going to build a max-heap using array representation. In particular, your program should: • Implement two methods of building a max-heap. o Using sequential insertions (its time complexity: ?(?????), by successively applying the regular add method). o Using the optimal method (its time complexity: ?(?), the “smart” way we learned in class). For both methods, your implementations need to keep track of how many swaps (swapping parent and child) are required...
Questions 1. How to create a comment in python? 2. The way to obtain user input from command line 3. List standard mathematical operators in python and explain them 4. List comparison operators in python 5. Explain while loop. Give example 6. Explain for loop. Give example 7. How to create infinite loop? And how to stop it? 8. Explain a built-in function ‘range’ for ‘for’ loop 9. Explain break statement 10. Explain continue statement 11. Explain pass statement 12....
starter code
To write a program using the starter code which is
TestLinkedList to see if the LinkedList program has bugs. It will
produce ether a pass or fail.More information is in the first two
pictures.
LinkedList.java
/**
* @author someone
*
* Implements a double-linked list with four errors
*/
public class LinkedList<E>
{
// The first and last nodes in the list
private Node<E> head, tail;
// Number of items stored in the list
private int size;
//...
python program do not use dictionary, list only Complete the program found in assignment4.py. You may not change any provided code. You may only complete the sections labeled: #YOUR CODE HERE Write a program that does the following. Reads the contents of Text from the include file, input.txt Create a dictionary of key-value pairs called index.txt Key: This represents the individual word Value: This is a list of the line number from Text where Key appeared Example: If the word...