1. WAP of Array implementation using size 3X3 matrix accept
values from user and print them on screen.
2. WAP to insert new value in array at first position or at mid
position given by user and also array holds some items.
3. WAP to create a linked list add some nodes in it and print its
values using simple traversing operation of linked list.
4. WAP to insert new node in linked list at first position, list
already hold some items.
5. WAP insert new node in linked list add at first ,add at end and
add at middle position.
6. WAP to create a doubly linked list add some nodes in it and
print its values using backward traversing.
7. WAP to implement circular list using arrays.
8. WAP to implement circular list using linked list.
9. WAP to implement of stack operations through function Push()
and Pop() using arrays.
10. WAP to implement Queue operation Insert() and Delete()
function in queue using arrays.
11. WAP to create binary tree and traverse them using recursive
function Preorder,Postorder and Inorder traversing.
12. WAP to implement Linear search operation using arrays.
13. WAP to implement Binary search operation using arrays.
14. WAP to implement Bubble sort operation using arrays.
15. WAP to implement Insertion sort operation using arrays.
16. WAP to implement Selection sort operation using arrays.
17. WAP to implement Merge sort operation using arrays.
18. WAP to implement Heap sort operation using arrays.
19. WAP to evaluate Post fix expression using stack.
20. WAP to implement conversion algorithm from Pre fix to Post fix
expression.
"Немного о функциональном программирование в JavaScript" Алексей КоваленкоFwdays
Все началось давно, еще в школе, классе эдак 7. Тогда учитель математики впервые произнесла фразу: "Игрек равно эф от икс". В то время я и не догадывался что это самое "эф от икс", является базовым принципом функционального программирования, да и не только функционального.
Functional Programming, Reactive Programming, Transducers, MapReduce и многое другое, так или иначе корнями уходит в то самое, незамысловатое f(x). Это настолько серьезная часть программирования, что ежеминутно, если не ежесекундно, по всему миру на клавиатуре нажимаются клавиши f, u, n, c, t, i, o, n. И нажимаются они именно в этой последовательности.
Пора принять тот факт, что без функционального программирования, программирования не существует!
Пора разобраться. Пора понять для чего нужны функции в программирование, как они должны работать и чем они могут быть полезны в ежедневной работе.
Learn the built-in mathematical functions in R. This tutorial is part of the Working With Data module of the R Programming course offered by r-squared.
"Немного о функциональном программирование в JavaScript" Алексей КоваленкоFwdays
Все началось давно, еще в школе, классе эдак 7. Тогда учитель математики впервые произнесла фразу: "Игрек равно эф от икс". В то время я и не догадывался что это самое "эф от икс", является базовым принципом функционального программирования, да и не только функционального.
Functional Programming, Reactive Programming, Transducers, MapReduce и многое другое, так или иначе корнями уходит в то самое, незамысловатое f(x). Это настолько серьезная часть программирования, что ежеминутно, если не ежесекундно, по всему миру на клавиатуре нажимаются клавиши f, u, n, c, t, i, o, n. И нажимаются они именно в этой последовательности.
Пора принять тот факт, что без функционального программирования, программирования не существует!
Пора разобраться. Пора понять для чего нужны функции в программирование, как они должны работать и чем они могут быть полезны в ежедневной работе.
Learn the built-in mathematical functions in R. This tutorial is part of the Working With Data module of the R Programming course offered by r-squared.
Presented at JAX London 2013
Clojure is the most interesting new language on the horizon, but many developers suffer from the Blub Paradox when they see the Lisp syntax. This talk introduces Clojure to developers who haven’t been exposed to it yet, focusing on the things that truly set it apart from other languages.
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
C++ это мультипарадигменный язык, поэтому программист сам может выбирать и совмещать структурный, объектно-ориентированный, обобщенный и функциональный подходы. Функциональный аспект C++ особенно расширился стандартом C++11: лямбда-функции, variadic templates, std::function, std::bind. (язык доклада: английский).
A tour of Python: slides from presentation given in 2012.
[Some slides are not properly rendered in SlideShare: the original is still available at http://www.aleksa.org/2015/04/python-presentation_7.html.]
A bird's eye view on some programming languages, focusing on concepts like typing, execution model or style. Presented on T3chFest 2016 in Leganés, Madrid, Spain.
Slides are discussing how to use arrays in Java and most important contents related to java arrays.
The given examples are supposed to have a good understanding of java arrays and how you apply those.
Kickstart your data science journey with this Python cheat sheet that contains code examples for strings, lists, importing libraries and NumPy arrays.
Find more cheat sheets and learn data science with Python at www.datacamp.com.
For this homework, you will write a program to create and manipulate.pdfherminaherman
For this homework, you will write a program to create and manipulate a simple linked list. For
each node in the linked list you will generate a random number, create a node that holds that
number, and insert that node into its sorted position in the linked list. Once the nodes are
inserted, you will traverse the list, printing the value held in each node. Then you will clean up
the list (deleting all the nodes) and exit the program. You will also learn about a tool that you can
use to help you check for memory errors in your code.
Specifications:
Define a struct appropriate for holding a random integer. This struct will also contain a \"next\"
pointer to reference a separate instance of the struct.
You may use the typedef keyword to give your struct a separate typename if you wish, but this is
not a requirement.
The program will read command line arguments. The first argument is the program name (as it
will always be) followed by a random number seed, the number of random numbers to generate
and ending with the Maximum Possible Value of the Random numbers generated (i.e. argc
should be 4).
Your program will use a \"dummy node\" for the linked list. In other words, the head of the list
will be an actual node, but the data field in that node will not be used for sorting purposes.
Your program must contain the following functions:
main() (for obvious reasons)
insertNodeSorted() - You may implement this either of two ways.
One way is to use the head of the list as one parameter and the integer value as the second. The
function will allocate memory for the node, initialize it and then insert it in the proper location in
the list.
The other way is to pass the head of the list as one parameter and a previously allocated and
initialized node as the other. The existing node is inserted in the proper location in the list.
printList() - Takes the head of the list as its only parameter, traverses the list, printing out the
data in sorted order.
deleteList() - Takes the head of the list as its only parameter, traverses the list, deleting all nodes.
The basic algorithm of your program is
Use a loop (based upon command line input values) that:
Generates a random number
Prints the number to stdout
Creates a node that contains that random number
Inserts the new node in sorted order into the existing list
Print the sorted linked list
Delete the linked list
You will use a Makefile to compile your program
Solution
#include
#include
#include
struct test_struct
{
int val;
struct test_struct *next;
};
struct test_struct *head = NULL;
struct test_struct *curr = NULL;
struct test_struct* create_list(int val)
{
printf(\"\ creating list with headnode as [%d]\ \",val);
struct test_struct *ptr = (struct test_struct*)malloc(sizeof(struct test_struct));
if(NULL == ptr)
{
printf(\"\ Node creation failed \ \");
return NULL;
}
ptr->val = val;
ptr->next = NULL;
head = curr = ptr;
return ptr;
}
struct test_struct* add_to_list(int val, bool add_to_end)
{
if(NULL == head)
{
retur.
Presented at JAX London 2013
Clojure is the most interesting new language on the horizon, but many developers suffer from the Blub Paradox when they see the Lisp syntax. This talk introduces Clojure to developers who haven’t been exposed to it yet, focusing on the things that truly set it apart from other languages.
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
C++ это мультипарадигменный язык, поэтому программист сам может выбирать и совмещать структурный, объектно-ориентированный, обобщенный и функциональный подходы. Функциональный аспект C++ особенно расширился стандартом C++11: лямбда-функции, variadic templates, std::function, std::bind. (язык доклада: английский).
A tour of Python: slides from presentation given in 2012.
[Some slides are not properly rendered in SlideShare: the original is still available at http://www.aleksa.org/2015/04/python-presentation_7.html.]
A bird's eye view on some programming languages, focusing on concepts like typing, execution model or style. Presented on T3chFest 2016 in Leganés, Madrid, Spain.
Slides are discussing how to use arrays in Java and most important contents related to java arrays.
The given examples are supposed to have a good understanding of java arrays and how you apply those.
Kickstart your data science journey with this Python cheat sheet that contains code examples for strings, lists, importing libraries and NumPy arrays.
Find more cheat sheets and learn data science with Python at www.datacamp.com.
For this homework, you will write a program to create and manipulate.pdfherminaherman
For this homework, you will write a program to create and manipulate a simple linked list. For
each node in the linked list you will generate a random number, create a node that holds that
number, and insert that node into its sorted position in the linked list. Once the nodes are
inserted, you will traverse the list, printing the value held in each node. Then you will clean up
the list (deleting all the nodes) and exit the program. You will also learn about a tool that you can
use to help you check for memory errors in your code.
Specifications:
Define a struct appropriate for holding a random integer. This struct will also contain a \"next\"
pointer to reference a separate instance of the struct.
You may use the typedef keyword to give your struct a separate typename if you wish, but this is
not a requirement.
The program will read command line arguments. The first argument is the program name (as it
will always be) followed by a random number seed, the number of random numbers to generate
and ending with the Maximum Possible Value of the Random numbers generated (i.e. argc
should be 4).
Your program will use a \"dummy node\" for the linked list. In other words, the head of the list
will be an actual node, but the data field in that node will not be used for sorting purposes.
Your program must contain the following functions:
main() (for obvious reasons)
insertNodeSorted() - You may implement this either of two ways.
One way is to use the head of the list as one parameter and the integer value as the second. The
function will allocate memory for the node, initialize it and then insert it in the proper location in
the list.
The other way is to pass the head of the list as one parameter and a previously allocated and
initialized node as the other. The existing node is inserted in the proper location in the list.
printList() - Takes the head of the list as its only parameter, traverses the list, printing out the
data in sorted order.
deleteList() - Takes the head of the list as its only parameter, traverses the list, deleting all nodes.
The basic algorithm of your program is
Use a loop (based upon command line input values) that:
Generates a random number
Prints the number to stdout
Creates a node that contains that random number
Inserts the new node in sorted order into the existing list
Print the sorted linked list
Delete the linked list
You will use a Makefile to compile your program
Solution
#include
#include
#include
struct test_struct
{
int val;
struct test_struct *next;
};
struct test_struct *head = NULL;
struct test_struct *curr = NULL;
struct test_struct* create_list(int val)
{
printf(\"\ creating list with headnode as [%d]\ \",val);
struct test_struct *ptr = (struct test_struct*)malloc(sizeof(struct test_struct));
if(NULL == ptr)
{
printf(\"\ Node creation failed \ \");
return NULL;
}
ptr->val = val;
ptr->next = NULL;
head = curr = ptr;
return ptr;
}
struct test_struct* add_to_list(int val, bool add_to_end)
{
if(NULL == head)
{
retur.
pleaase I want manual solution forData Structures and Algorithm An.pdfwasemanivytreenrco51
pleaase I want manual solution for
Data Structures and Algorithm Analysis in C++, Third Edition
By Clifford A. Shaffer
because my question from this book.page270 ,question 7.4
The implementation for Mergesort given in Section 7.4 takes an array as input and sorts that
array. At the beginning of Section 7.4 there is a simple pseudocode implementation for sorting a
linked list using Mergesort. Implement both a linked list-based version of Mergesort and the
array-based version of Mergesort, and compare and analyze their running times.
Solution
Linked list:
#include
#include
struct node
{
int data;
struct node* next;
};
struct node* SortedMerge(struct node* a, struct node* b);
void FrontBackSplit(struct node* source,
struct node** frontRef, struct node** backRef);
void MergeSort(struct node** headRef)
{
struct node* head = *headRef;
struct node* a;
struct node* b;
if ((head == NULL) || (head->next == NULL))
{
return;
}
FrontBackSplit(head, &a, &b);
MergeSort(&a);
MergeSort(&b);
*headRef = SortedMerge(a, b);
}
struct node* SortedMerge(struct node* a, struct node* b)
{
struct node* result = NULL;
if (a == NULL)
return(b);
else if (b==NULL)
return(a);
if (a->data <= b->data)
{
result = a;
result->next = SortedMerge(a->next, b);
}
else
{
result = b;
result->next = SortedMerge(a, b->next);
}
return(result);
}
void FrontBackSplit(struct node* source,
struct node** frontRef, struct node** backRef)
{
struct node* fast;
struct node* slow;
if (source==NULL || source->next==NULL)
{
*frontRef = source;
*backRef = NULL;
}
else
{
slow = source;
fast = source->next;
while (fast != NULL)
{
fast = fast->next;
if (fast != NULL)
{
slow = slow->next;
fast = fast->next;
}
}
*frontRef = source;
*backRef = slow->next;
slow->next = NULL;
}
}
void printList(struct node *node)
{
while(node!=NULL)
{
printf(\"%d \", node->data);
node = node->next;
}
}
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;
}
int main()
{
struct node* res = NULL;
struct node* a = NULL;
push(&a, 15);
push(&a, 10);
push(&a, 5);
push(&a, 20);
push(&a, 3);
push(&a, 2);
MergeSort(&a);
printf(\"\ Sorted Linked List is: \ \");
printList(a);
getchar();
return 0;
}
Time complexity:o(nlogn)
Array :
#include
#include
void merge(int arr[], int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
int L[n1], R[n2];
for (i = 0; i < n1; i++)
L[i] = arr[l + i];
for (j = 0; j < n2; j++)
R[j] = arr[m + 1+ j];
i = 0; // Initial index of first subarray
j = 0;
k = l;
while (i < n1 && j < n2)
{
if (L[i] <= R[j])
{
arr[k] = L[i];
i++;
}
else
{
arr[k] = R[j];
j++;
}
k++;
}
while (i < n1)
{
arr[k] = L[i];
i++;
k++;
}
while (j < n2)
{
arr[k] = R[j];
j++;
k++;
}
}
void mergeSort(int arr[], int l, int r)
{
if (l < r)
{
int m = l+(r-l)/2;
// Sort first and second halves
mergeSort(arr, l, m);
mergeSort(arr, m+1, r);
merge(arr, l, m, r);
}
}
void printArray(int A[], i.
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfvishalateen
Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking
on the orange arrow next to main.cpp at the top of the coding window. The Node class has three
member variables: a double data value, a pointer to the next node, and a pointer to the previous
node. Each member variable is protected. So code outside of the class must use the provided
getter and setter member functions to get or set a member variable. Node.h is read only, since no
changes are required. Step 2: Implement the Insert() member function A class for a sorted,
doubly-linked list is declared in SortedNumberList.h. Implement the SortedNumberList class's
Insert() member function. The function must create a new node with the parameter value, then
insert the node into the proper sorted position in the linked list. Ex: Suppose a
SortedNumberList's current list is 23 47.25 86, then Insert(33.5) is called. A new node with data
value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's sorted order
and yielding: 23 35.5 47.25 86 Step 3: Test in develop mode Code in main() takes a space-
separated list of numbers and inserts each into a SortedNumberList. The list is displayed after
each insertion. Ex: If input is 77 15 -42 63.5 then output is: List after inserting 77: 77 List after
inserting 15: 15 77 List after inserting -42: -42 15 77 List after inserting 63.5: -42 15 63.5 77 Try
various program inputs, ensuring that each outputs a sorted list. Step 4: Implement the Remove()
member function Implement the SortedNumberList class's Remove() member function. The
function takes a parameter for the number to be removed from the list. If the number does not
exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the
number is removed from the list and true is returned. Uncomment the commented-out part in
main() that reads a second input line and removes numbers from the list. Test in develop mode to
ensure that insertion and removal both work properly, then submit code for grading. Ex: If input
is 84 72 19 61 19 84 then output is: List after inserting 84: 84 List after inserting 72: 72 84 List
after inserting 19: 19 72 84 List after inserting 61: 19 61 72 84 List after removing 19: 61 72 84
List after removing 84: 61 72
main.cpp
#include
#include
#include
#include "Node.h"
#include "SortedNumberList.h"
using namespace std; void PrintList(SortedNumberList& list); vector SpaceSplit(string source);
int main(int argc, char *argv[]) { // Read the line of input numbers string inputLine; getline(cin,
inputLine); // Split on space character vector terms = SpaceSplit(inputLine); // Insert each value
and show the sorted list's contents after each insertion SortedNumberList list; for (auto term :
terms) { double number = stod(term); cout << "List after inserting " << number << ": " << endl;
list.Insert(number); PrintList(list); } /* // Read the input line with numbers to remove getline(cin,
inputLi.
hello- please dont just copy from other answers- the following is the.docxIsaac9LjWelchq
hello. please dont just copy from other answers, the following is the code that is already have and can u modified it for the following instructions.
instructions ----A LinkNode structure or class which will have two attributes -
a data attribute, and
a pointer attribute to the next node.
The data attribute of the LinkNode should be a reference/pointer of the Currency class of Lab 2.
Do not make it an inner class or member structure to the SinglyLinkedList class of #2 below.
A SinglyLinkedList class which will be composed of three attributes -
a count attribute,
a LinkNode pointer/reference attribute named as and pointing to the start of the list and
a LinkNode pointer/reference attribute named as and pointing to the end of the list.
Since this is a class, make sure all these attributes are private.
The class and attribute names for the node and linked list are the words in bold in #1 and #2.
For the Linked List, implement the following linked-list behaviors as explained in class -
getters/setters/constructors/destructors, as needed, for the attributes of the class.
createList method in addition to the constructor - this is optional for overloading purposes.
destroyList method in place of or in addition to the destructor - this is optional for overloading purposes,
addCurrency method which takes a Currency object and a node index value as parameters to add the Currency to the list at that index.
removeCurrency method which takes a Currency object as parameter and removes that Currency object from the list and may return a copy of the Currency.
removeCurrency overload method which takes a node index as parameter and removes the Currency object at that index and may return a copy of the Currency.
findCurrency method which takes a Currency object as parameter and returns the node index at which the Currency is found in the list.
getCurrency method which takes an index values as a parameter and returns the Currency object.
printList method which returns a string of all the Currency objects in the list in the order of index, tab spaced.
isListEmpty method which returns if a list is empty or not.
countCurrency method which returns a count of Currency nodes in the list.
Any other methods you think would be useful in your program.
A Stack class derived from the SinglyLinkedList but with no additional attributes and the usual stack methods -
constructor and createStack (optional) methods,
push which takes a Currency object as parameter and adds it to the top of the stack.
pop which takes no parameter and removes and returns the Currency object from the top of the stack.
peek which takes no parameter and returns a copy of the Currency object at the top of the stack.
printStack method which returns a string signifying the contents of the stack from the top to bottom, tab spaced.
destructor and/or destroyStack (optional) methods.
Ensure that the Stack objects do not allow Linked List functions to be used on them.
A Queue class derived from the SinglyLink.
Sorted number list implementation with linked listsStep 1 Inspec.pdfalmaniaeyewear
Sorted number list implementation with linked lists
Step 1: Inspect the Node.java file
Inspect the class declaration for a doubly-linked list node in Node.java. Access Node.java by
clicking on the orange arrow next to LabProgram.java at the top of the coding window. The
Node class has three fields:
a double data value,
a reference to the next node, and
a reference to the previous node.
Each field is protected. So code outside of the class must use the provided getter and setter
methods to get or set a field.
Node.java is read only, since no changes are required.
Step 2: Implement the insert() method
A class for a sorted, doubly-linked list is declared in SortedNumberList.java. Implement the
SortedNumberList class's insert() method. The method must create a new node with the
parameter value, then insert the node into the proper sorted position in the linked list. Ex:
Suppose a SortedNumberList's current list is 23 47.25 86, then insert(33.5) is called. A new
node with data value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's
sorted order and yielding: 23 35.5 47.25 86
Step 3: Test in develop mode
Code in main() takes a space-separated list of numbers and inserts each into a SortedNumberList.
The list is displayed after each insertion. Ex: If input is
then output is:
Try various program inputs, ensuring that each outputs a sorted list.
Step 4: Implement the remove() method
Implement the SortedNumberList class's remove() method. The method takes a parameter for the
number to be removed from the list. If the number does not exist in the list, the list is not
changed and false is returned. Otherwise, the first instance of the number is removed from the
list and true is returned.
Uncomment the commented-out part in main() that reads a second input line and removes
numbers from the list. Test in develop mode to ensure that insertion and removal both work
properly, then submit code for grading. Ex: If input is
then output is:
Given templates:
LabProgram.java
import java.util.Scanner;
import java.io.PrintWriter;
public class LabProgram {
// Prints the SortedNumberList's contents, in order from head to tail
public static void printList(SortedNumberList list) {
Node node = list.head;
while (null != node) {
System.out.print(node.getData() + " ");
node = node.getNext();
}
System.out.println();
}
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
String inputLine;
// Read the line of input numbers
inputLine = scnr.nextLine();
// Split on space character
String[] terms = inputLine.split(" ");
// Insert each value and show the sorted list's contents after each insertion
SortedNumberList list = new SortedNumberList();
for (Object term : terms) {
double number = Double.parseDouble(term.toString());
System.out.println("List after inserting " + number + ": ");
list.insert(number);
printList(list);
}
/*
// Read the input line with numbers to remove
inputLine = scnr.nextLine();
terms = inputLine.split(" ".
Please solve the following problem using C++- Thank you Instructions-.docxPeterlqELawrenceb
Please solve the following problem using C++. Thank you
Instructions: ----
A LinkNode structure or class which will have two attributes -
a data attribute, and
a pointer attribute to the next node.
The data attribute of the LinkNode should be a reference/pointer of the Currency class of Lab 2.
Do not make it an inner class or member structure to the SinglyLinkedList class of #2 below.
A SinglyLinkedList class which will be composed of three attributes -
a count attribute,
a LinkNode pointer/reference attribute named as and pointing to the start of the list and
a LinkNode pointer/reference attribute named as and pointing to the end of the list.
Since this is a class, make sure all these attributes are private.
The class and attribute names for the node and linked list are the words in bold in #1 and #2.
For the Linked List, implement the following linked-list behaviors as explained in class -
getters/setters/constructors/destructors, as needed, for the attributes of the class.
createList method in addition to the constructor - this is optional for overloading purposes.
destroyList method in place of or in addition to the destructor - this is optional for overloading purposes,
addCurrency method which takes a Currency object and a node index value as parameters to add the Currency to the list at that index.
removeCurrency method which takes a Currency object as parameter and removes that Currency object from the list and may return a copy of the Currency.
removeCurrency overload method which takes a node index as parameter and removes the Currency object at that index and may return a copy of the Currency.
findCurrency method which takes a Currency object as parameter and returns the node index at which the Currency is found in the list.
getCurrency method which takes an index values as a parameter and returns the Currency object.
printList method which returns a string of all the Currency objects in the list in the order of index, tab spaced.
isListEmpty method which returns if a list is empty or not.
countCurrency method which returns a count of Currency nodes in the list.
Any other methods you think would be useful in your program.
A Stack class derived from the SinglyLinkedList but with no additional attributes and the usual stack methods -
constructor and createStack (optional) methods,
push which takes a Currency object as parameter and adds it to the top of the stack.
pop which takes no parameter and removes and returns the Currency object from the top of the stack.
peek which takes no parameter and returns a copy of the Currency object at the top of the stack.
printStack method which returns a string signifying the contents of the stack from the top to bottom, tab spaced.
destructor and/or destroyStack (optional) methods.
Ensure that the Stack objects do not allow Linked List functions to be used on them.
A Queue class derived from the SinglyLinkedList but with no additional attributes and the usual queue methods -
constructor and creat.
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.
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdffortmdu
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) 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 #4 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 deleteLast(nodeType*& last, nodeType* first);
int main()
{
nodeType *firs.
Download the ppt for animation of Singly linked list insertion and deletion
Note: if you have downloaded it in .pdf, convert it to .pptx and press F5 for animation.
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfinfo114
Need done for Date Structures please!
4.18 LAB: Sorted number list implementation with linked lists
Step 1: Inspect the Node.h file
Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking
on the orange arrow next to main.cpp at the top of the coding window. The Node class has three
member variables:
a double data value,
a pointer to the next node, and
a pointer to the previous node.
Each member variable is protected. So code outside of the class must use the provided getter and
setter member functions to get or set a member variable.
Node.h is read only, since no changes are required.
Step 2: Implement the Insert() member function
A class for a sorted, doubly-linked list is declared in SortedNumberList.h. Implement the
SortedNumberList class's Insert() member function. The function must create a new node with
the parameter value, then insert the node into the proper sorted position in the linked list. Ex:
Suppose a SortedNumberList's current list is 23 47.25 86, then Insert(33.5) is called. A new node
with data value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's
sorted order and yielding: 23 35.5 47.25 86
Step 3: Test in develop mode
Code in main() takes a space-separated list of numbers and inserts each into a SortedNumberList.
The list is displayed after each insertion. Ex: If input is
then output is:
Try various program inputs, ensuring that each outputs a sorted list.
Step 4: Implement the Remove() member function
Implement the SortedNumberList class's Remove() member function. The function takes a
parameter for the number to be removed from the list. If the number does not exist in the list, the
list is not changed and false is returned. Otherwise, the first instance of the number is removed
from the list and true is returned.
Uncomment the commented-out part in main() that reads a second input line and removes
numbers from the list. Test in develop mode to ensure that insertion and removal both work
properly, then submit code for grading. Ex: If input is
then output is:
main.cpp
#include <iostream>
#include <string>
#include <vector>
#include "Node.h"
#include "SortedNumberList.h"
using namespace std;
void PrintList(SortedNumberList& list);
vector<string> SpaceSplit(string source);
int main(int argc, char *argv[]) {
// Read the line of input numbers
string inputLine;
getline(cin, inputLine);
// Split on space character
vector<string> terms = SpaceSplit(inputLine);
// Insert each value and show the sorted list's contents after each insertion
SortedNumberList list;
for (auto term : terms) {
double number = stod(term);
cout << "List after inserting " << number << ": " << endl;
list.Insert(number);
PrintList(list);
}
/*
// Read the input line with numbers to remove
getline(cin, inputLine);
terms = SpaceSplit(inputLine);
// Remove each value
for (auto term : terms) {
double number = stod(term);
cout << "List after removing " << number << ": " << endl;
list.Remove(number.
coding in C- Create a function called reverseList that takes the head.docxtienlivick
coding in C;
Create a function called reverseList that takes the head of a linked list, reverses the order of all the nodes. For example, if the list contained 1, 2, 3, 4 in its nodes, the list will now contain 4, 3, 2, 1.
please add a main test.
Solution
Please find the required program below:
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node* next;
};
void push(struct node** head, int new_element)
{
struct node* new_node =
(struct node*) malloc(sizeof(struct node));
new_node->data = new_element;
new_node->next = (*head);
(*head) = new_node;
}
void printList(struct node *head)
{
struct node *temp = head;
while(temp != NULL)
{
printf(\"%d \", temp->data);
temp = temp->next;
}
}
void reverseList(struct node** head)
{
struct node* prev = NULL;
struct node* current = *head;
struct node* next;
while (current != NULL)
{
next = current->next;
current->next = prev;
prev = current;
current = next;
}
*head = prev;
}
int main()
{
struct node* head = NULL;
push(&head, 12);
push(&head, 14);
push(&head, 5);
push(&head, 8);
printf(\"\ Linked list Before Reversing :\ \");
printList(head);
reverseList(&head);
printf(\"\ Linked list After Reversing :\ \");
printList(head);
}
--------------------------------------------------------------------------------
OUTPUT:
Linked list Before Reversing :
8Â Â 5Â Â 14Â Â 12
Linked list After Reversing :
12Â Â 14Â Â 5Â Â 8
.
This document contains some programs of C using Data structures, like Stack, LinkedList, queue, Fibonacci series, addition and multiplication of two matrices,etc.
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfrozakashif85
Write a Java Class to Implement a Generic Linked List
Your list must be implemented as a singly-linked list of generic nodes, where each Node object
has two instance variables: an object of the “type variable” class, and a pointer to the next node
on the list.
Your class will contain separate methods to handle each of the operations read from a data file
(see II., below)
Your class will also override toString() to return the objects on the list in the order in which they
occur.
Write a Test Class for Your LinkedList Class
Your main method will read list operation instructions from a data file, until end-of-file and call
the appropriate LinkedList method to execute each one.
After each operation is executed, print out the operation and the updated list.
The data file to be used is on the class web site and the operations are:
APPEND X - Append object X to the end of the list
ADD N X - Insert object X as the new Nth element in the list, increasing the size of the list by 1
E.g. Suppose the list is:
head -> 1 -> 2 -> 3 -> 4->null
After ADD 3 7 it would be:
head -> 1 -> 2 -> 7 -> 3 -> 4->null
DELETE N – Remove the Nth object from the list
SWAP M N - Interchange the positions of the Mth and Nth
objects on the list
For credit, the two nodes must actually \"trade places\" in the list, and not merely swap their data
values
REVERSE - Reverse the order of the objects on the list
This must be done by reversing the order of the nodes themselves, rather than by swapping the
data stored
To get credit for your reverse() method, it must use either one of these 2 algorithms:
For each node on the list except the current “head”
node, delete the node and insert it as the new head
Use your swap() method
6. CLEAR – Clear the list (make it empty)
No credit will be given for programs that use any additional data structures – either from the Java
API or programmer defined -, other than your own LinkedList class
txt file:
Solution
//Java Program to Implement Singly Linked List
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
/* Class Node */
class Nodes
{
protected Object data;
protected Nodes next;
/* Constructor */
public Nodes()
{
next = null;
data = null;
}
/* Constructor */
public Nodes(Object d,Nodes n)
{
data = d;
next = n;
}
/* Function to set link to next Node */
public void setLink(Nodes n)
{
next = n;
}
/* Function to set data to current Node */
public void setData(Object d)
{
data = d;
}
/* Function to get link to next node */
public Nodes getLink()
{
return next;
}
/* Function to get data from current Node */
public Object getData()
{
return data;
}
}
/* Class linkedList */
class linkList
{
protected Nodes start;
protected Nodes end ;
public int size ;
/* Constructor */
public linkList()
{
start = null;
end = null;
size = 0;
}
/* Function to check if list is empty */
public boolean isEmpty()
{
return start == null;
}
/* Function to get size of list */
public int getSize()
{
return .
UNIT-I
Review of Software Engineering: Overview of software evolution, SDLC, Testing Process, Terminologies in
Testing: Error, Fault, Failure, Verification, Validation, Difference between Verification and Validation,
Test Cases, Testing Suite, Test Oracles, Impracticality of Testing All data; Impracticality of testing All
Paths. Verification: Verification methods, SRS verification, Source code reviews, User documentation
verification, and Software project audit, Tailoring Software Quality Assurance Program by Reviews,
Walkthrough, Inspection, and Configuration Audits.
UNIT–II (8)
Functional Testing: Boundary Value Analysis, Equivalence Class Testing, Decision Table Based Testing, Cause
Effect Graphing Technique. Structural Testing: Control flow testing, Path testing, Independent paths, Generation
of graph from program, Identification of independent paths, Cyclomatic Complexity, Data Flow Testing,
Mutation Testing.
UNIT-III (8)
Regression Testing: What is Regression Testing? Regression Test cases selection, reducing the number of test
cases, Code coverage prioritization technique. Reducing the number of test cases: Prioritization guidelines,
Priority category, Scheme, Risk Analysis.
What is cloud computing?
Advantages of cloud computing.
Disadvantages of cloud computing.
Mainly Four Deployment Models.
What is private cloud?
DRAWBACK
Two models for cloud services can be delivered in a private cloud.
Cloud Computing Service Models.
HOW TO DOWNLOAD MICROSOFT WORD IN ANDROID, and How to convert doc file into ...TEJVEER SINGH
In this pdf, you can learn how to convert doc file convert into pdf via android mobile without any third-party software.
And also learn how to install Microsoft word in android.
and also learn how Gmail doc file converts into a pdf file.
The ‘Multi Banking System’ Interface is targeted to the future banking solution for the users who have multiple bank accounts in different banks. This interface integrates all existing banks and provides business solutions for both retail and corporate. System Involves
• This interface integrates all existing banks and provides business solutions for both retailers and corporate.
• This system acts as a standard interface between the clients and the banks
• Users who have accounts in various banks can log in here and can make any kind of transactions.
• In the backend, the system will take care of the entire obligation required in order to carry on transaction smoothly.
The Multi Banking System Interface is targeted to the future banking solution for the users who are having multiple bank accounts in multiple banks. This interface integrates all existing banks and provides business solutions for both retail and corporate. This system acts as a standard interface between the clients and all the banks, By using this portal any client who maintains accounts in various banks can directly log on to Multi Banking System Interface and make any kind of transactions. In the backend, the system will take care of the entire obligation required in order to carry on transaction smoothly.
Explain Hardware and Software technologies used in your project work.
Define the objective and motivation of your mini-project Work in reference to your Project Title.
Present and Explain DFDs of Project (DFD-0, DFD-1, DFD-2 …).
Present and Explain ER Diagram of Project.
Explain Front-End or User Interfaces (One by One) with Purpose and working.
Explain Back-End or Database Tables used in your project.
Explain Usability or Ultimate output of your project work.
Explain the Drawback or limitations of your project work.
Explain how this work can be carried out in future for improvement.
Define topology and explain different types of topologies of the network?
Explain error detection and error correction techniques?
Explain the flow control mechanism?
#How to install mongoDB and also setup pathTEJVEER SINGH
In this tutorial you have to see how to install MongoDB database or
MongoDB shell.
Also setup path of MongoDB then you will directly start via cmd command prompt by using command mongo --db
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracaleDriver
gives the error at JDBC connect with java program.
then this type of error will be remove in this slide or via ppt.
1. Create Tables and Insert data (First data using Insert query rest can be feeded.)
2. Write an SQL query to print details of the Workers whose FIRST_NAME ends with ‘h’ and contains six alphabets.
3. Change Last_Name Columns name to Surname.
4. Write an SQL query to print details of the Workers whose SALARY lies between 100000 and 500000.
5. Write an SQL query to fetch the count of employees working in the department ‘Admin’.
6. Write an SQL query to fetch the no. of workers for each department in the descending order.
7. Write an SQL query to print details of the Workers who are also Managers.
8. Select Top 10 salaries and Employees Full name from Worker table.
9. Write an SQL query to fetch the list of employees with the same salary.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Event Management System Vb Net Project Report.pdfKamal Acharya
In present era, the scopes of information technology growing with a very fast .We do not see any are untouched from this industry. The scope of information technology has become wider includes: Business and industry. Household Business, Communication, Education, Entertainment, Science, Medicine, Engineering, Distance Learning, Weather Forecasting. Carrier Searching and so on.
My project named “Event Management System” is software that store and maintained all events coordinated in college. It also helpful to print related reports. My project will help to record the events coordinated by faculties with their Name, Event subject, date & details in an efficient & effective ways.
In my system we have to make a system by which a user can record all events coordinated by a particular faculty. In our proposed system some more featured are added which differs it from the existing system such as security.
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfKamal Acharya
The College Bus Management system is completely developed by Visual Basic .NET Version. The application is connect with most secured database language MS SQL Server. The application is develop by using best combination of front-end and back-end languages. The application is totally design like flat user interface. This flat user interface is more attractive user interface in 2017. The application is gives more important to the system functionality. The application is to manage the student’s details, driver’s details, bus details, bus route details, bus fees details and more. The application has only one unit for admin. The admin can manage the entire application. The admin can login into the application by using username and password of the admin. The application is develop for big and small colleges. It is more user friendly for non-computer person. Even they can easily learn how to manage the application within hours. The application is more secure by the admin. The system will give an effective output for the VB.Net and SQL Server given as input to the system. The compiled java program given as input to the system, after scanning the program will generate different reports. The application generates the report for users. The admin can view and download the report of the data. The application deliver the excel format reports. Because, excel formatted reports is very easy to understand the income and expense of the college bus. This application is mainly develop for windows operating system users. In 2017, 73% of people enterprises are using windows operating system. So the application will easily install for all the windows operating system users. The application-developed size is very low. The application consumes very low space in disk. Therefore, the user can allocate very minimum local disk space for this application.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
Courier management system project report.pdfKamal Acharya
It is now-a-days very important for the people to send or receive articles like imported furniture, electronic items, gifts, business goods and the like. People depend vastly on different transport systems which mostly use the manual way of receiving and delivering the articles. There is no way to track the articles till they are received and there is no way to let the customer know what happened in transit, once he booked some articles. In such a situation, we need a system which completely computerizes the cargo activities including time to time tracking of the articles sent. This need is fulfilled by Courier Management System software which is online software for the cargo management people that enables them to receive the goods from a source and send them to a required destination and track their status from time to time.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Automobile Management System Project Report.pdfKamal Acharya
The proposed project is developed to manage the automobile in the automobile dealer company. The main module in this project is login, automobile management, customer management, sales, complaints and reports. The first module is the login. The automobile showroom owner should login to the project for usage. The username and password are verified and if it is correct, next form opens. If the username and password are not correct, it shows the error message.
When a customer search for a automobile, if the automobile is available, they will be taken to a page that shows the details of the automobile including automobile name, automobile ID, quantity, price etc. “Automobile Management System” is useful for maintaining automobiles, customers effectively and hence helps for establishing good relation between customer and automobile organization. It contains various customized modules for effectively maintaining automobiles and stock information accurately and safely.
When the automobile is sold to the customer, stock will be reduced automatically. When a new purchase is made, stock will be increased automatically. While selecting automobiles for sale, the proposed software will automatically check for total number of available stock of that particular item, if the total stock of that particular item is less than 5, software will notify the user to purchase the particular item.
Also when the user tries to sale items which are not in stock, the system will prompt the user that the stock is not enough. Customers of this system can search for a automobile; can purchase a automobile easily by selecting fast. On the other hand the stock of automobiles can be maintained perfectly by the automobile shop manager overcoming the drawbacks of existing system.
Halogenation process of chemical process industries
Most Important C language program
1. INDEX
S.no Content Page
no.
1. WAP of Array implementation using size 3X3 matrix accept
values from user and print them on screen.
2. WAP to insert new value in array at first position or at mid
position given by user and also array holds some items.
3. WAP to create a linked list add some nodes in it and print its
values using simple traversing operation of linked list.
4. WAP to insert new node in linked list at first position, list
already hold some items.
5. WAP insert new node in linked list add at first ,add at end and
add at middle position.
6. WAP to create a doubly linked list add some nodes in it and
print its values using backward traversing.
7. WAP to implement circular list using arrays.
8. WAP to implement circular list using linked list.
9. WAP to implement of stack operations through function Push()
and Pop() using arrays.
10. WAP to implement Queue operation Insert() and Delete()
function in queue using arrays.
11. WAP to create binary tree and traverse them using recursive
function Preorder,Postorder and Inorder traversing.
12. WAP to implement Linear search operation using arrays.
13. WAP to implement Binary search operation using arrays.
14. WAP to implement Bubble sort operation using arrays.
15. WAP to implement Insertion sort operation using arrays.
16. WAP to implement Selection sort operation using arrays.
17. WAP to implement Merge sort operation using arrays.
18. WAP to implement Heap sort operation using arrays.
19. WAP to evaluate Post fix expression using stack.
20. WAP to implement conversion algorithm from Pre fix to Post fix
expression.
2. Question 1:- WAP of Array implementation using size 3X3 matrix accept values from user and print them on
screen.
#include <stdio.h>
int main()
{
int matrix[10][10];
int i,j,r,c;
printf("Enter number of Rows :");
scanf("%d",&r);
printf("Enter number of Cols :");
scanf("%d",&c);
printf("nEnter matrix elements :n");
for(i=0;i< r;i++)
{
for(j=0;j< c;j++)
{
printf("Enter element [%d,%d] : ",i+1,j+1);
scanf("%d",&matrix[i][j]);
}
}
printf("nMatrix is :n");
for(i=0;i< r;i++)
{
for(j=0;j< c;j++)
{
printf("%dt",matrix[i][j]);
}
printf("n"); /*new line after row elements*/
}
return 0;
}
3. OUTPUT
Enter number of Rows :3
Enter number of Cols :3
Enter matrix elements :
Enter element [1,1] : 1
Enter element [1,2] : 2
Enter element [1,3] : 3
Enter element [2,1] : 4
Enter element [2,2] : 5
Enter element [2,3] : 6
Enter element [3,1] : 7
Enter element [3,2] : 8
Enter element [3,3] : 9
Matrix is :
1 2 3
4 5 6
7 8 9
==========================================================================================
Question 2:- WAP to insert new value in array at first position or at mid position given by user and also array
holds some items.
#include <stdio.h>
int main()
{
int arr[50],n,i,key,loc;
printf("Enter size :");
scanf("%d",&n);
printf("Enter %d elements:",n);
for(i=0; i<n; i++)
{
scanf("%d", &arr[i]);
4. }
printf("Enter element to insert:");
scanf("%d", &key);
printf("Enter loc to insert:");
scanf("%d", &loc);
for(i=(n-1); i>=loc; i--)
{
arr[i+1]=arr[i];
}
arr[loc]=key;
for(i=0;i<n;i++)
{
printf("%dn",arr[i]);
}
return 0;
}
OUTPUT
Enter size :5
Enter 5 elements:10
20
30
40
50
Enter element to insert:90
Enter loc to insert:0
90
10
20
30
40
5. =======================================================================================
Question 3:- WAP to create a linked list add some nodes in it and print its values using simple traversing
operation of linked list.
#include<stdio.h>
#include<stdlib.h>
struct Node
{
int data;
struct Node *next;
};
// This function prints contents of linked list starting from the given node
void printList(struct Node *n)
{
while (n != NULL)
{
printf(" %d ", n->data);
n = n->next;
}
}
int main()
{
struct Node* head = NULL;
struct Node* second = NULL;
struct Node* third = NULL; // allocate 3 nodes in the heap
head = (struct Node*)malloc(sizeof(struct Node));
second = (struct Node*)malloc(sizeof(struct Node));
third = (struct Node*)malloc(sizeof(struct Node));
head->data = 1; //assign data in first node
head->next = second; // Link first node with second
second->data = 2; //assign data to second node
second->next = third;
third->data = 3; //assign data to third node
6. third->next = NULL;
printList(head);
return 0;
}
OUTPUT
1 2 3
==================================================================================
Question 5:- WAP insert new node in linked list add at first,add at end and add at middle position.
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node* link; // link is a global variable
};
struct node* root= NULL;
int len; // after append fucnction
void addatend(void);
void addatbegin(void);
void addatafter(void);
void display();
int length();
void main()
{
int ch;
while(1)
{
printf("Single linked list operations : n");
printf("1.Add at end n");
printf("2.Add at begin n");
printf("3.Add at after n");
7. printf("4.Display n");
printf("5.Length");
printf("6.Quit n");
printf("Enter your choice: ");
scanf("%d",&ch);
switch(ch)
{
case 1 : addatend();
break;
case 2 : addatbegin();
break;
case 3 : addatafter();
break;
case 4 : display();
break;
case 5 : len=length();
printf("Length : %dnn",len);
break;
case 6 : exit(1);
default : printf("Invalid input n");
}
}
}
void addatend()
{
struct node* temp; // temp is a local variable
temp = (struct node*)malloc(sizeof(struct node));
printf("Enter node data :"); // how to read the information from the end user
scanf("%d", &temp->data);
temp->link= NULL; // create a first node
if(root == NULL) //LIST IS EMPTY
8. {
root = temp;
}
else
{
struct node* p; // how to insert remaining node
p = root;
while(p->link!= NULL) // check every time
{
p = p->link;
}
p->link =temp;
}
}
void addatafter()
{
struct node* temp, *P;
int loc,len,i=1;
printf("Enter location:");
scanf("%d",&loc);
len=length();
if(loc>len)
{
printf("Invalid location n");
printf("currently list is having %d node",len);
}
else
{
P=root;
while(i<loc)
{
9. P=P->link;
i++;
}
temp=(struct node*)malloc(sizeof(struct node));
temp->link=P->link; // right
P->link=temp; //left
}
}
void addatbegin(void)
{
struct node* temp;
temp=(struct node*)malloc(sizeof(struct node));
printf("Enter the node data:");
scanf("%d",&temp->data);
temp->link=NULL;
if(root==NULL)
{
root=temp;
}
else
{
temp->link=root; // right
root = temp; // left
}
}
void display() //how to display all the element in the list
{
struct node* temp;
temp = root;
if(temp== NULL)
{
10. printf("List is empty nn");
}
else
{
while(temp!= NULL)
{
printf("%d-->",temp->data); // print link data
temp = temp->link;
}
printf("nn");
} }
int length() // length function
{
int count =0;
struct node* temp;
temp = root ;
while(temp != NULL)
{
count++;
temp= temp->link;
}
return count;
}
OUTPUT
Single linked list operations :
1.Add at end
2.Add at begin
3.Add at after
4.Display
5.Length
6.Quit
11. Enter your choice: 1
Enter node data :2
Single linked list operations :
1.Add at end
2.Add at begin
3.Add at after
4.Display
5.Length
6.Quit
Enter your choice: 2
Enter the node data:4
Single linked list operations :
1.Add at end
2.Add at begin
3.Add at after
4.Display
5.Length
6.Quit
Enter your choice: 4
4-->2-->
=======================================================================================
Question 6:- WAP to create a doubly linked list add some nodes in it and print its values using backward
traversing.
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *left;
struct node *right;
};
struct node *root = NULL;
struct node *last = NULL;
12. void insert();
void printlist();
void printbackward();
int main()
{
insert(10);
insert(20);
insert(30);
insert(1);
insert(40);
insert(56);
printlist();
printbackward();
return 0;
}
void insert(int data) //Create Linked List
{
struct node *temp;
temp = (struct node*) malloc(sizeof(struct node));
temp->data = data;
temp->left = NULL;
temp->right = NULL;
if(root==NULL) // If head is empty, create new list
{
root = temp;
return;
}
else
{
struct node* P;
P=root;
13. while(P->right!=NULL) // move to the end of the list
P = P->right;
P->right = temp; // Insert link at the end of the list
last = temp;
temp->left = P;
}
}
void printlist() //display the list
{
struct node *temp ;
temp=root;
printf("n[root] <=>");
while(temp != NULL) //start from the beginning
{
printf(" %d <=>",temp->data);
temp = temp->right;
}
printf(" [NULL]n");
}
void printbackward() //display the list
{
struct node *temp = last;
printf("n[root] <=>");
while(temp != NULL) //start from the beginning
{
printf(" %d <=>",temp->data);
temp = temp->left;
}
printf(" [NULL]n");
}
OUTPUT
14. [root] <=> 10 <=> 20 <=> 30 <=> 1 <=> 40 <=> 56 <=> [NULL]
[root] <=> 56 <=> 40 <=> 1 <=> 30 <=> 20 <=> 10 <=> [NULL]
==========================================================================================
Question 7:- WAP to implement circular linked list using array
# include<stdio.h>
# define size 5
int cqueue[size];
int front = -1;
int rear = -1;
void delete();
void insert();
void display();
int main()
{
int choice,element;
while(1)
{
printf("1.Insertn");
printf("2.Deleten");
printf("3.Displayn");
printf("4.Quitn");
printf("Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1 :
printf("Input the element for insertion in queue : ");
scanf("%d", &element);
insert(element);
break;
case 2 :
delete();
18. Enter your choice : 1
Input the element for insertion in queue : 3
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 1
Input the element for insertion in queue : 5
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice : 3
Queue elements :
3 5
1.Insert
2.Delete
3.Display
4.Quit
======================================================================================
Question 8:- WAP to implement circular list using linked list.
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *next;
};
struct node *front=NULL,*rear=NULL,*temp;
void create();
void delete();
19. void display();
int main()
{
int ch;
while(1)
{
printf("n 1 Enter the element : ");
printf("n 2 Delete the element : ");
printf("n 3 Display the elements : ");
printf("n 4 Exit from main : ");
printf("n Enter your choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
create();
break;
case 2:
delete();
break;
case 3:
display();
break;
case 4:
return 1;
default:
printf("nInvalid choice :");
}
}
return 0;
}
25. }
void peek()
{
if(isEmpty())
{
printf("peek element : %d n", stack[top]);
}
}
void traverse()
{
if(isEmpty())
{
printf("Stack is empty n");
}
else
{
int i;
printf("stack elements : n");
for(i=0; i<=top; i++)
{
printf("%d n", stack[i]);
}
}
}
OUTPUT
1. Push
2. Pop
3. Peek
4. Traverse
5. Quit
Enter your choice :1
26. Enter element :4
4 pushed
1. Push
2. Pop
3. Peek
4. Traverse
5. Quit
========================================================================================
Ques 10:-WAP to implement Queue operation insert() and delete() function in queue using arrays.
#include <stdio.h>
#include <stdlib.h>
# define CAPACITY 5
int queue[CAPACITY];
int front = 0;
int rear = 0;
void delete();
void insert();
int main()
{
int choice,element;
while(1)
{
printf("1.Insertn");
printf("2.Deleten");
printf("4.Quitn");
printf("Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1 :
insert();
27. break;
case 2 :
delete();
break;
case 4:
break;
default:
printf("Wrong choicen");
}
}
return 0;
}
void insert()
{
if(CAPACITY==rear)
{
printf("Queue is fulln");
}
else
{
int element;
printf("Enter the element :");
scanf("%d",&element);
queue[rear]=element;
rear++;
}
}
void delete()
{
int i;
if(front==rear)
28. {
printf("Queue is Empty");
}
else
{
printf("deleted : %d", queue[front]);
for(i=1; i<rear-1; i++)
{
queue[i]=queue[i+1];
}
rear--;
}
}
OUTPUT
1.Insert
2.Delete
3.Quit
Enter your choice : 1
Enter the element :4
1.Insert
2.Delete
3.Quit
Enter your choice : 1
Enter the element :6
1.Insert
2.Delete
3.Quit
Enter your choice : 2
deleted : 4
==========================================================================================
Ques 11:- WAP to create binary tree and traverse them using recursive function Preorder,Postorder and
Inorder traversing.
30. inorder(P->right);
}
void preorder(struct node* P)
{
if (P == NULL)
return;
printf("%d ", P->data);
preorder(P->left);
preorder(P->right);
}
int main()
{
struct node *root;
root = newNode(1);
root->left = newNode(2);
root->right = newNode(3);
root->left->left = newNode(4);
root->left->right = newNode(5);
printf("nPreorder traversal of binary tree is n");
preorder(root);
printf("nInorder traversal of binary tree is n");
inorder(root);
printf("nPostorder traversal of binary tree is n");
postorder(root);
return 0;
}
OUTPUT
Preorder traversal of binary tree is
1 2 4 5 3
Inorder traversal of binary tree is
31. 4 2 5 1 3
Postorder traversal of binary tree is
4 5 2 3 1
=======================================================================================
Ques 12:- WAP to implement Linear search operation using arrays.
#include <stdio.h>
int main()
{
int array[100], search, i, n;
printf("Enter number of elements in arrayn");
scanf("%d", &n);
printf("Enter %d integer(s)n", n);
for (i = 0; i < n; i++)
scanf("%d", &array[i]);
printf("Enter a number to searchn");
scanf("%d", &search);
for (i = 0; i < n; i++)
{
if (array[i] == search) /* If required element is found */
{
printf("%d is present at location %d.n", search, i+1);
break;
}
}
if (i == n)
printf("%d isn't present in the array.n", search);
return 0;
}
OUTPUT
Enter number of elements in array
4
32. Enter 4 integer(s)
2 5 8 3
Enter a number to search
8
8 is present at location 3.
==========================================================================================
Ques 13:- WAP to implement Binary search opertation using arrays.
#include <stdio.h>
int main()
{
int i, first, last, middle, n, search, array[100];
printf("Enter number of elementsn");
scanf("%d",&n);
printf("Enter %d integersn", n);
for (i = 0; i < n; i++)
{
scanf("%d",&array[i]);
}
printf("Enter value to findn");
scanf("%d", &search);
first = 0;
last = n - 1;
middle = (first+last)/2;
while (first <= last) {
if (array[middle] < search)
first = middle + 1;
else if (array[middle] == search) {
printf("%d found at location %d.n", search, middle+1);
break;
}
else
33. last = middle - 1;
middle = (first + last)/2;
}
if (first > last)
printf("Not found! %d isn't present in the list.n", search);
return 0;
}
OUTPUT
Enter number of elements
5
Enter 5 integers
4 5 3 8 9
Enter value to find
8
8 found at location 4.
=========================================================================================
Ques 14:- WAP to implement Bubble sort opertation using arrays.
#include <stdio.h>
#include<stdlib.h>
int main()
{
int array[100], n, i, j, swap;
printf("Enter number of elementsn");
scanf("%d", &n);
printf("Enter %d integersn", n);
for (i = 0; i < n; i++)
{
scanf("%d", &array[i]);
}
for (i = 0 ; i < n - 1; i++)
{
34. for (j = 0 ; j < n - i - 1; j++)
{
if (array[j] > array[j+1]) /* For decreasing order use < */
{
swap = array[j];
array[j] = array[j+1];
array[j+1] = swap;
}
}
}
printf("Sorted list in ascending order:n");
for (i = 0; i < n; i++)
{
printf("%dn", array[i]);
}
return 0;
}
OUTPUT
Enter number of elements
5
Enter 5 integers
5 4 7 9 2
Sorted list in ascending order:
2
4
5
7
9
======================================================================================
Question 15:- WAP to implement Insertion sort operation using arrays.
#include <math.h>
35. #include <stdio.h>
/* Function to sort an array using insertion sort*/
void insertionSort(int arr[], int n)
{
int i, key, j;
for (i = 1; i < n; i++)
{
key = arr[i];
j = i - 1;
while (j >= 0 && arr[j] > key)
{
arr[j + 1] = arr[j];
j = j - 1;
}
arr[j + 1] = key;
}
}
void printArray(int arr[], int n)
{
int i;
printf("nList after sortingn");
for (i = 0; i < n; i++)
printf("%d ", arr[i]);
printf("n");
}
int main()
{
int i;
int arr[5] = { 12, 11, 13, 5, 6 };
printf("List before sortingn");
for(i = 1; i <= arr[4]; i++)
36. {
printf("%d ", arr[i]);
}
int n = sizeof(arr) / sizeof(arr[0]);
insertionSort(arr, n);
printArray(arr, n);
return 0;
}
OUTPUT
List before sorting
11 13 5 6 0 1
List after sorting
5 6 11 12 13
=======================================================================================
Question 16:- WAP to implement Selection sort operation using arrays.
#include <stdio.h>
int main()
{
int array[100], n, i, j, position, swap;
printf("Enter number of elementsn");
scanf("%d", &n);
printf("Enter %d integersn", n);
for (i = 0; i < n; i++)
{
scanf("%d", &array[i]);
}
for (i = 0; i < (n - 1); i++)
{
position = i;
for (j = i + 1; j < n; j++)
{
37. if (array[position] > array[j])
position = j;
}
if (position != i)
{
swap = array[i];
array[i] = array[position];
array[position] = swap;
}
}
printf("Sorted list in ascending order:n");
for (i = 0; i < n; i++)
{
printf("%dn", array[i]);
}
return 0;
}
OUTPUT
Enter number of elements
5
Enter 5 integers
5 8 9 3 2
Sorted list in ascending order:
2
3
5
8
9
======================================================================================
Question 17:- WAP to implement Merge sort operation using arrays.
#include <stdio.h>
41. if(s+1 <=i-1 && (a[s]<a[s+1]))
s=s+1;
if(s>i-1)
s=-1;
}
a[f]= value;
}
printf("The sorted list is n");
for(i=0; i<n; i++)
{
printf("%dn",a[i]);
}
getch();
}
OUTPUT
Enter the number of elements:
5
Enter 5 elements one by one
6 4 2 8 1
The sorted list is
1
2
6
4
8
=========================================================================================
Question 19:- WAP to evaluate Post fix expression using stack.
#include<stdio.h>
#include<ctype.h>
# define MAXSTACK 100
# define POSTFIXSIZE 100
42. int stack[MAXSTACK];
int top = -1 ;
void push(int item)
{
if(top >= MAXSTACK -1)
{
printf("stack over flow");
return;
}
else
{
top = top + 1 ;
stack[top]= item;
}
}
int pop()
{
int item;
if(top <0)
{
printf("stack under flow");
}
else
{
item = stack[top];
top = top - 1;
return item;
}
}
void EvalPostfix(char postfix[])
{
43. int i ;
char ch;
int val;
int A, B ;
for (i = 0 ; postfix[i] != ')'; i++)
{
ch = postfix[i];
if (isdigit(ch))
{
push(ch - '0');
}
else if (ch == '+' || ch == '-' || ch == '*' || ch == '/')
{
A = pop();
B = pop();
switch (ch)
{
case '*':
val = B * A;
break;
case '/':
val = B / A;
break;
case '+':
val = B + A;
break;
case '-':
val = B - A;
break;
}
push(val); /* push the value obtained above onto the stack */
44. }
}
printf( " n Result of expression evaluation : %d n", pop()) ;
}
int main()
{
int i ;
char postfix[POSTFIXSIZE];
printf("Use only four operator +,-,*,/ and also single digit only.n");
printf( "nEnter postfix expression and last used ')' : ");
for (i = 0 ; i <= POSTFIXSIZE - 1 ; i++)
{
scanf("%c", &postfix[i]);
if ( postfix[i] == ')' )
break;
}
EvalPostfix(postfix);
return 0;
}
OUTPUT
Use only four operator +,-,*,/ and also single digit only.
Enter postfix expression and last used ')' : 56+)
Result of expression evaluation : 11
==========================================================================================
Question 20:- WAP to implement conversion algorithm from Pre fix expression to Post fix expression.
#include<stdio.h>
#include<string.h>
void push(char item[],int *top,char s[][20])
{
*top=*top+1;
strcpy(s[*top],item);
45. }
void *pop(int *top,char s[][20])
{
char *item;
item=s[*top];
*top=*top-1;
return item;
}
void pre_post(char prefix[],char postfix[])
{
char s[20][20];
int top,i;
char symbol,temp[2];
char *op1,*op2;
top=-1;
strrev(prefix);
for(i=0;i<strlen(prefix);i++)
{
symbol=prefix[i];
temp[0]=symbol;
temp[1]='0';
switch (symbol)
{
case '+':
case '-':
case '*':
case '/':
case '^':
op1=pop(&top,s);
op2=pop(&top,s);
strcpy(postfix,op1);