This document contains the code for various operations on singly linked lists in C language such as insertion, deletion, searching, counting, reversing, merging, and splitting nodes. It includes function definitions and main program to demonstrate a menu driven program to perform these operations and print the list. The functions work recursively to traverse the list and perform the desired operation by updating next pointers.
Numerical Methods with Computer ProgrammingUtsav Patel
This report includes computer programming of some of the basic numerical methods. The programming language used is C++. Outputs of the programs are attached in the form of a screenshot. It can be helpful in the assignments on programming.
Our new blog post featuring some common python programming patterns and their C++ equivalents is now up!
Leave us a comment below and let us know what you'd like to see covered in our future posts!
█ Read More
Technical Insights: Introduction to GraphQL|goo.gl/d7PyXH
Les tests unitaires se sont pas limités au code des applications, des tests peuvent également être effectués sur les données et les schémas des bases de données.
Conférence donnée lors du meetup PostgreSQL le 22 juin 2016 à Nantes
Numerical Methods with Computer ProgrammingUtsav Patel
This report includes computer programming of some of the basic numerical methods. The programming language used is C++. Outputs of the programs are attached in the form of a screenshot. It can be helpful in the assignments on programming.
Our new blog post featuring some common python programming patterns and their C++ equivalents is now up!
Leave us a comment below and let us know what you'd like to see covered in our future posts!
█ Read More
Technical Insights: Introduction to GraphQL|goo.gl/d7PyXH
Les tests unitaires se sont pas limités au code des applications, des tests peuvent également être effectués sur les données et les schémas des bases de données.
Conférence donnée lors du meetup PostgreSQL le 22 juin 2016 à Nantes
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfaassecuritysystem
C++ Language
** Dynamic Memory **
There are 7 files in this project, and they are down below. And I guess the professor wants us to
modify the set.cpp make sure the numbers are entered by the user to be set dynamically. If you
pay attention to the set.cpp I marked in bold a section that may be needed to be changed. I have
put all the codes down so that you can copy them to your computer to have an idea of how they
work together. Only that Set.cpp must be modified so the number of elements can be set
dynamically during the program's execution. And please can you be more specific about what
line of code needs to be replaced?
Here are the professor's instructions.
** Note: The goal of this assignment is to MODIFY the existing code. **
Implement a dynamically allocated version of the mathematical concept of a 'set'. First, examine
the provided library and driver (in main) for a statically allocated Set class. You may also want
to refresh your mathematical memory of the set concept before proceeding.
Now that you are familiar with how the Set class works, let's make it work better. Currently, the
user is limited to a certain maximum number of elements in their Set. Change it so the number of
elements can be set dynamically during the program's execution.
Extend the driver to test all the ADT's operations.
** Things to Consider **
1. If your set is implemented in dynamic memory:
1a. How do you access the members?
1b. How and when do you re-size the memory?
HERE are the CODE files:.
main.cpp
include <iostream>
#include <cctype>
#include "input.h"
#include "set.h"
using namespace std;
int main(void)
{
Set x, y, z;
bool quit;
long newone;
do
{
cout << "Enter a long integer: ";
cin >> newone;
if (x.ismember(newone))
{
cout << "You've already entered that!" << endl;
}
else
{
x.add_elem(newone);
cout << "Value added to list!" << endl;
}
quit = toupper(get_in_set("YyNn", "Would you like to enter more? ")) == 'N';
} while (!quit && !x.full());
cout << "Overall, you entered: " << endl;
x.output(cout);
cout << endl;
cout << "Please enter a set of long integers: ";
x.input(cin);
cout << endl << "You entered:\n";
x.output(cout);
cout << endl;
cout << "Please enter another set of long integers: ";
y.input(cin);
cout << endl << "You entered:\n";
y.output(cout);
cout << endl;
cout << "The union of the two sets is:\n";
z = x;
z.union_with(y);
z.output(cout);
cout << endl;
cout << "The intersection of the two sets is:\n";
z = x;
z.intersection(y);
z.output(cout);
cout << endl;
return 0;
}
input.cpp
#include "input.h"
#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;
// Boundaries are assumed to be solid -- low <= value <= high.
// Enum to say which end is to be bounded...
//
// enum BoundType { Low, High, Both };
// Bounded entry function for long integers...
//
long get_bounded(long low,
long high,
const char prompt[] /* = "Enter bounded value: " */,
BoundType which_end /* = Both */)
{
long value;
cout << prompt;
cin >> value;
while (((.
Highlighted notes of:
Introduction to CUDA C: NVIDIA
Author: Blaise Barney
From: GPU Clusters, Lawrence Livermore National Laboratory
https://computing.llnl.gov/tutorials/linux_clusters/gpu/NVIDIA.Introduction_to_CUDA_C.1.pdf
Blaise Barney is a research scientist at Lawrence Livermore National Laboratory.
files/Heap.h
#ifndef HEAP_H
#define HEAP_H
#include <vector>
#include <stdexcept> // std::out_of_range
#include <math.h> // pow()
using namespace std;
template<typename T>
class Heap
{
private:
vector<T> _items; // Main vector of elements for heap storage
/**
* Used to take unsorted data and heapify it
*/
void buildHeap()
{
for (int i = _items.size() / 2; i >= 0; i--)
{
percolateDown(i);
}
}
/*********************************************************************/
/********************* Microassignment zone *************************/
/**
* Percolates the item specified at by index down
* into its proper location within a heap.
* Used for dequeue operations and array to heap conversions
* MA TODO: Implement percolateDown!
*/
void percolateDown(int index)
{
}
/**
* Percolate up from a given index to fix heap property
* Used in inserting new nodes into the heap
* MA TODO: Implement percolateUp
*/
void percolateUp( int current_position )
{
}
/************************** Microassigment zone DONE *********************/
public:
/**
* Default empty constructor
*/
Heap()
{
}
/**
* Constructor with a vector of elements
*/
Heap(const vector<T> &unsorted)
{
for (int i = 0; i < unsorted.size(); i++)
{
_items.push_back(unsorted[i]);
}
buildHeap();
}
/**
* Adds a new item to the heap
*/
void insert(T item)
{
int current_position = size(); // Get index location
_items.push_back(item); // Add data to end
percolateUp( current_position ); // Adjust up, as needed
}
/**
* Returns the top-most item in our heap without
* actually removing the item from the heap
*/
T& getFirst()
{
if( size() > 0 )
return _items[0];
else
throw std::out_of_range("No elements in Heap.");
}
/**
* Removes minimum value from heap and returns it to the caller
*/
T deleteMin()
{
int last_index = size() - 1; // Calc last item index
int root_index = 0; // Root index (for readability)
T min_item = _items[root_index]; // Keep item to return
_items[root_index] = _items[last_index]; // Move last item to root
_items.erase(_items.end() - 1); // Erase last element entry
percolateDown(0); // Fix heap property
return min_item;
}
/**
* Returns true if heap is empty, else false
*/
bool isEmpty() const
{
return _items.size() == 0;
}
/**
* Returns current quantity of elements in heap (N)
*/
int size() const
{
return _items.size();
}
/**
* Return heap data in order from the _items vector
*/
string to_s() const
{
string ret = "";
for(int i = 0; i < _items.size(); i++)
{
ret += to_string(_items[i]) + " ";
}
return ret;
}
/**
...
Write a C program that reads the words the user types at the command.pdfSANDEEPARIHANT
Write a C program that reads the words the user types at the command prompt (using the \'int
argc, char * argv[] and store each unique letter in a Binary Search Tree. When a duplicate is
encountered do not store the letter again and instead keep track of the count in the tree. Once the
Binary Search tree has been created print out the tree both inorder and reverse order. Also print
the highest and lowest alphabetically letter in the tree if any.
Solution
# include
# include
# include
typedef struct BST {
int data;
struct BST *lchild, *rchild;
} node;
void insert(node *, node *);
void preorder(node *);
findMinimum(struct node* root)
findMaximum(struct node* root)
void reverseLevelOrder(struct node* root)
void main(int argc,char argv) {
char argv = \'N\';
int key;
node *new_node, *root, *tmp, *parent;
node *get_node();
root = NULL;
clrscr();
printf(\"\ Program For Binary Search Tree \");
do {
printf(\"\ 1.Create\");
printf(\"\ 2.Search\");
printf(\"\ 3.Recursive Traversals\");
printf(\"\ 4.Exit\");
printf(\"\ Enter your choice :\");
scanf(\"%d\", &argc);
switch (argc) {
case 1:
do {
new_node = get_node();
printf(\"\ Enter The Element \");
scanf(\"%d\", &new_node->data);
if (root == NULL) /* Tree is not Created */
root = new_node;
else
insert(root, new_node);
printf(\"\ Want To enter More Elements?(y/n)\");
argv= getch();
} while (argv == \'y\');
break;
case 2:
if (root == NULL)
printf(\"Tree Is Not Created\");
else {
printf(\"\ The Preorder display : \");
preorder(root);
}
break;
}
} while (argv != 4);
}
/*
Get new Node
*/
node *get_node() {
node *temp;
temp = (node *) malloc(sizeof(node));
temp->lchild = NULL;
temp->rchild = NULL;
return temp;
}
/*
This function is for creating a binary search tree
*/
void insert(node *root, node *new_node) {
if (new_node->data < root->data) {
if (root->lchild == NULL)
root->lchild = new_node;
return newNode(key);
else
insert(root->lchild, new_node);
}
if (new_node->data > root->data) {
if (root->rchild == NULL)
root->rchild = new_node;
return newNode(key);
else
insert(root->rchild, new_node);
}
}
if (key == node->key)
{
(node->count)++;
return node;
}
/*
This function displays the tree in preorder fashion
*/
void preorder(node *temp) {
if (temp != NULL) {
printf(\"%d\", temp->data);
preorder(temp->lchild);
preorder(temp->rchild);
}
}
// Returns maximum value in a given Binary Tree
int findMaximum(struct node* root)
{
// Base case
if (root == NULL)
return INT_MAXIMUM;
// Return maximum of 3 values:
// 1) Root\'s data 2) Max in Left Subtree
// 3) Max in right subtree
int res = root->data;
int lres = findMaximum (root->lchild);
int rres = findMaximum (root->rchild);
if (lres > res)
res = lres;
if (rres > res)
res = rres;
return res;
}
// Returns minimum value in a given Binary Tree
int findMinimum(struct node* root)
{
// Base case
if (root == NULL)
return INT_MINIMUM;
// Return minimum of 3 values:
// 1) Root\'s data 2) Max in Left Subtree
// 3) Max in right subtree
int res = root->data;
int lres = findMinimum(r.
In C++ I need help with this method that Im trying to write fillLi.pdffantoosh1
In C++ I need help with this method that I'm trying to write: fillListFromFile( ) : void -- this
method will add elements to the list from a file called linkedListData1.txt HINT: this is where
you will keep track of the number of elements in the list
I have all of the other methods, but I'm stuck on this one and I've added it as the last method in
the application. The code I have so far is below.
.cpp file:
.h file:
main:
#include
#include
#include
#include "Node.h"
using namespace std;
void displayList(Node*);
void insertFront(Node** head, int value);
void insertBack(Node** ptrToHead, int value);
void insertAfter(Node* previous, int value);
void deleteAtN(Node** ptrToHead, int n);
void deleteNode(Node** ptrToHead, int searchVal);
void clearList(Node**);
bool searchVal(Node** head, int value);
int countFrequencyOf(Node** ptrTohead, int value);
int size(Node** ptrTohead);
void displayFromFrontToN(Node** ptrToHead, int n);
void displayFromNToEnd(Node** ptrToHead, int n);
void insertInOrder(Node** head, Node* ptrToHead);
void displayInRows(Node** ptrToHead);
int main()
{
Node* node1 = new Node();
node1->setValue(10);
Node* node2 = new Node();
node2->setValue(20);
Node* node3 = new Node();
node3->setValue(30);
node1->next = node2;
node2->next = node3;
Node* head = node1;
displayList(head);
insertFront(&head, 5);
displayList(head);
insertBack(&head, 50);
displayList(head);
insertBack(&head, 60);
displayList(head);
insertAfter(node2, 25);
displayList(head);
deleteAtN(&head, 2);
displayList(head);
deleteNode(&head, 50);
displayList(head);
clearList(&head);
displayList(head);
insertFront(&head, 5);
insertFront(&head, 10);
insertFront(&head, 20);
insertBack(&head, 50);
searchVal(&head, 50);
displayList(head);
countFrequencyOf(&head, 25);
displayList(head);
insertBack(&head, 25);
insertFront(&head, 25);
countFrequencyOf(&head, 25);
displayList(head);
size(&head);
cout << "add one item to list" << endl;
insertBack(&head, 25);
size(&head);
displayList(head);
cout << "Display From Front To N" << endl;
displayFromFrontToN(&head, 4);
cout << "Display From N To End" << endl;
displayFromNToEnd(&head, 3);
cout << "Display In Rows" << endl;
displayInRows(&head);
insertFront(&head, 12);
insertFront(&head, 17);
insertFront(&head, 22);
insertBack(&head, 58);
cout << "Display In Rows" << endl;
displayInRows(&head);//call displayInRows()
return 0;
}//end main()
void displayList(Node* ptr) {
if (ptr == nullptr)
cout << "empty list" << endl;
else {
while (ptr != nullptr) {
cout << ptr->getValue() << endl;
ptr = ptr->next;
}
}
cout << "---------------------------" << endl;
}//end displayList()
void insertFront(Node** head, int value) {
Node* newNode = new Node();
newNode->setValue(value);
//cout<< newNode->getValue() << endl;
newNode->next = *head;
*head = newNode;
}
void insertBack(Node** ptrToHead, int value) {
Node* newNode = new Node();
newNode->setValue(value);
newNode->next = nullptr;
if (*ptrToHead == nullptr)
{
*ptrToHead = newNode;
}//end if
else
{
Node* last .
Help to implement delete_node get_succ get_pred walk and.pdfcontact32
Help to implement delete_node, get_succ, get_pred, walk, and tree_search in the script
following the given structure:
#include "bst.h"
// ---------------------------------------
// Node class
// Default constructor
Node::Node() {
// TODO: Implement this
key = 0;
parent = nullptr;
left = nullptr;
right = nullptr;
}
// Constructor
Node::Node(int in) {
// TODO: Implement this
key = in;
parent = nullptr;
left = nullptr;
right = nullptr;
}
// Destructor
Node::~Node() {
// TODO: Implement this
delete left;
delete right;
}
// Add parent
void Node::add_parent(Node* in) {
// TODO: Implement this
parent = in;
}
// Add to left of current node
void Node::add_left(Node* in) {
// TODO: Implement this
left = in;
if (in != nullptr) {
in->add_parent(this);
}
}
// Add to right of current node
void Node::add_right(Node* in) {
// TODO: Implement this
right = in;
if (in != nullptr) {
in->add_parent(this);
}
}
// Get key
int Node::get_key()
{
// TODO: Implement this
return key;
}
// Get parent node
Node* Node::get_parent()
{
// TODO: Implement this
return parent;
}
// Get left node
Node* Node::get_left()
{
// TODO: Implement this
return left;
}
// Get right node
Node* Node::get_right()
{
// TODO: Implement this
return right;
}
// Print the key to ostream to
// Do not change this
void Node::print_info(ostream& to)
{
to << key << endl;
}
// ---------------------------------------
// ---------------------------------------
// BST class
// Walk the subtree from the given node
void BST::inorder_walk(Node* in, ostream& to)
{
// TODO: Implement this
if (in != nullptr) {
inorder_walk(in->get_left(), to);
in->print_info(to);
inorder_walk(in->get_right(), to);
}
}
// Constructor
BST::BST()
{
// TODO: Implement this
root = nullptr;
}
// Destructor
BST::~BST()
{
// TODO: Implement this
delete root;
}
// Insert a node to the subtree
void BST::insert_node(Node* in)
{
// TODO: Implement this
Node* curr = root;
Node* par = nullptr;
while (curr != nullptr) {
par = curr;
if (in->get_key() < curr->get_key()) {
curr = curr->get_left();
} else {
curr = curr->get_right();
}
}
in->add_parent(par);
if (par == nullptr) {
root = in;
} else if (in->get_key() < par->get_key()) {
par->add_left(in);
} else {
par->add_right(in);
}
}
// Delete a node to the subtree
void BST::delete_node(Node* out)
{
// TODO: Implement this
}
// minimum key in the BST
Node* BST::tree_min()
{
// TODO: Implement this
return get_min(root);
}
// maximum key in the BST
Node* BST::tree_max()
{
// TODO: Implement this
return get_max(root);
}
// Get the minimum node from the subtree of given node
Node* BST::get_min(Node* in)
{
// TODO: Implement this
if (in == nullptr) {
return nullptr;
}
while (in->get_left() != nullptr) {
in = in->get_left();
}
return in;
}
// Get the maximum node from the subtree of given node
Node* BST::get_max(Node* in)
{
// TODO: Implement this
if (in == nullptr) {
return nullptr;
}
while (in->get_right() != nullptr) {
in = in->get_right();
}
return in;
}
// Get successor of the given node
Node* BS.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
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.