#include<iostream>
#include<cstdlib>
using namespace std;
// struct declaration
struct Node {
int data;
Node *next;
};
/*
add a node to linkedlist
*/
void addNode(Node *ll,int d){
while(ll->next != NULL){
ll = ll->next;
}
struct Node *temp = (struct Node*)malloc(sizeof(struct
Node));
temp->data = d;
temp->next = NULL;
ll->next = temp;
}
/*
function to display linkedlist
*/
void display(Node *ll){
while(ll!=NULL){
cout << ll->data << "->";
ll = ll->next;
}
cout << endl;
}
/*
function to count the number of times the integer 5 occurs in the
given linked list
*/
int count5(Node *top){
// base case if top is null return zero
if(top == NULL){
return 0;
}
// if data is 5 add 1 to recursive call
else if(top->data == 5){
return 1+count5(top->next);
}
else{
return count5(top->next);
}
}
/*
function the add a numer n to the linked list integers
*/
void recAddn(Node *top, int n){
if(top == NULL){
return;
}
else{
top->data = top->data + n;
return recAddn(top->next,n);
}
}
/*
reverse string function
*/
void reverseString()
{
char c;
scanf("%c", &c);
if( c != '$')
{
reverseString();
cout << c;
}
}
/*
function to return the sum of integers in the linked list
*/
int sum(Node *top){
if(top == NULL){
return 0;
}
else{
return top->data + sum(top->next);
}
}
int main() {
/*top node */
Node *top;
top = (struct Node*)malloc(sizeof(struct Node));
top->data = 1;
top->next = NULL;
// add 10 nodes through for loop
for(int i=2;i<11;i++){
addNode(top,i);
}
addNode(top,5);
// print the linked list
display(top);
cout << "Count of 5 in linkedlist = " << count5(top)
<< endl;
// call the sum function
cout << "Sum of integers in linkedList: " << sum(top)
<< endl;
// call the recAddn function with n = 5
recAddn(top,5);
// dispaly the linked list after adding n
cout << "Linked List after calling recAddn : "<<
endl;
display(top);
cout << "Enter a sentence:";
reverseString();
}
/*
sample output
1->2->3->4->5->6->7->8->9->10->5->
Count of 5 in linkedlist = 2
Sum of integers in linkedList: 60
Linked List after calling recAddn :
6->7->8->9->10->11->12->13->14->15->10->
Enter a sentence:abcd$
dcba
*/
Implement F(A,B,C)=(A+B+C)(A’+C’)(B+C’) using a 2x1 Multiplexer and using a 4x1 Multiplexer.
Data Structures Using C++: Using C++: Write the definition of the function, nodeCount, that returns the number of nodes in a binary tree. Add this function to the class binaryTreeType and create a program to test this function. Read the tree definitions from files.
All questions in C#: using System; using System.Linq; using System.Data.Linq; using System.Xml.Linq; using System.Collections; and that the following array is defined: string[] colors = { ""green"", ""brown"", ""blue"", ""red"" }; var query = from c in colors where c.Length > 3 orderby c.Length select c; what type is variable query? int string IEnumerable<string> IEnumerable<int> IQueryable<string> IQueryable<int> In current .NET Framework, what assembly must be included in a project to use the SoundPlayer class? System System.Media corelib Sound In Generic Method...
1. a. Using C++, represent the following graph using adjacency matrix, and implement DFS by using stack (define it using class) to traverse the graph. b. Similarly, implement BFS (define queue using class) to traverse the graph c.When node 6 is printed, what numbers are in the stack (for DFS) and queue (for BFS) respectively? Draw pictures to show them.
1. a. Using C++, represent the following graph using adjacency matrix, and implement DFS by using stack (define it using...
write the code using c++ ( textbook from Date Structure using c++) Write a function that generates the squares of the first N integers and then separates these squares into 2 sets so that difference between the sum of the squares in the first set and the the sum of the squares in the second set is a small as possible. The function's parameter is N. The function returns the two sets of squares and two sums of their squares.
A. Let a and c be real numbers, with a<c. Using the axioms of the real number system, prove there exists a real number b so that a<b<c.
Using C++ write two Factorial functions. One using a loop and another using recursion. The program must be in module as well
an example of a code using pointers in C.
Using any of the inference or replacement rules, fill in the justifications for the proof: A > B B > C C > A A > ~C // ~A & ~C
Using C Language Design and implement an application that illustrates scope using an int and a double. Make sure to format the double with 2 decimals only.