diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /659/CH13 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '659/CH13')
-rwxr-xr-x | 659/CH13/EX1.cs/Casestudy1.sci | 88 | ||||
-rwxr-xr-x | 659/CH13/EX1.cs/Casestudy1_output.PNG | bin | 0 -> 16620 bytes | |||
-rwxr-xr-x | 659/CH13/EX13.3/exm13_3.sci | 65 | ||||
-rwxr-xr-x | 659/CH13/EX13.3/exm13_3_output.PNG | bin | 0 -> 15642 bytes | |||
-rwxr-xr-x | 659/CH13/EX13.4/exm13_4.sci | 76 | ||||
-rwxr-xr-x | 659/CH13/EX13.4/exm13_4_output.PNG | bin | 0 -> 18901 bytes | |||
-rwxr-xr-x | 659/CH13/EX13.5/exm13_5.sci | 68 | ||||
-rwxr-xr-x | 659/CH13/EX13.5/exm13_5_output.PNG | bin | 0 -> 17066 bytes | |||
-rwxr-xr-x | 659/CH13/EX2.cs/Casestudy2.sci | 68 | ||||
-rwxr-xr-x | 659/CH13/EX2.cs/Casestudy2_output.PNG | bin | 0 -> 15369 bytes |
10 files changed, 365 insertions, 0 deletions
diff --git a/659/CH13/EX1.cs/Casestudy1.sci b/659/CH13/EX1.cs/Casestudy1.sci new file mode 100755 index 000000000..4a08e55b7 --- /dev/null +++ b/659/CH13/EX1.cs/Casestudy1.sci @@ -0,0 +1,88 @@ +// Case Study: Chapter:13 ,Page No.:434
+// 1.Insertion in a sorted list
+
+funcprot(0);
+//Create the list
+function [List]=create(list1)
+ global List;
+ // Create the current node
+ list1.number=input("Input a number(Type -999 to end); ");
+ if list1.number==-999 then
+ list1.next=NULL;
+ list1.add=NULL;
+ else
+ list1.add=list1.add+1;
+ list1.next=NULL;
+ List(i)=list1;
+ if(i==1) then
+
+ else
+ List(i-1).next=List(i).add
+ end
+ i=i+1;
+ create(list1);// Create the next node
+ end
+ return;
+endfunction
+function []=print1(list1)
+ if list1(i)(1).next~=NULL then
+ printf("%d--->",list1(i)(1).number);//Print current item
+ i=i+1;
+ if list1(i)(1).next==NULL then
+ printf("%d",list1(i)(1).number);
+ end
+ print1(list1);//Move to next item
+ end
+ return;
+endfunction
+function [List]=insert(list1)
+ global List;
+ x=input("Input number to be inserted: ");//Read the number
+ //find the location so that number could be placed in sorted order
+ while (list1(i)(1).next~=NULL)
+ if(list1(i)(1).number>=x) then
+ break;
+ end
+ i=i+1;
+ end
+ key=i;
+ //Insetion at end
+ if(list1(i)(1).next==NULL & list1(i)(1).number < x) then
+ list1(i+1)(1).number=x;
+ list1(i+1)(1).add=i+1;
+ list1(i+1)(1).next=NULL;
+ list1(i)(1).next=list1(i+1)(1).add;
+ List=list1;
+ return;
+ end
+ i=1;
+ while (list1(i)(1).next~=NULL)
+ i=i+1;
+ end
+ j=i+1;
+ //Key node found and insert new node or item
+ while(list1(i)(1).add~=key)
+ list1(i+1)(1).number=list1(i)(1).number;
+ i=i-1;
+ end
+ list1(i+1)(1).number=list1(i)(1).number
+ list1(i)(1).number=x;
+ list1(j)(1).add=j;
+ list1(j)(1).next=NULL;
+ list1(j-1)(1).next=list1(j)(1).add;
+ List=list1;
+endfunction
+
+global List;
+NULL=0;i=1;
+//Create the structure i.e. node
+node=struct('number',0,'add',0,'next',0);
+head=node;
+//Calling the functions
+printf("Input a sorted(ascending) list");
+List=create(head);
+printf("\nOriginal List: ");
+print1(List);
+List=insert(List);
+printf("\nNew List: ");
+print1(List);
\ No newline at end of file diff --git a/659/CH13/EX1.cs/Casestudy1_output.PNG b/659/CH13/EX1.cs/Casestudy1_output.PNG Binary files differnew file mode 100755 index 000000000..79b8a5623 --- /dev/null +++ b/659/CH13/EX1.cs/Casestudy1_output.PNG diff --git a/659/CH13/EX13.3/exm13_3.sci b/659/CH13/EX13.3/exm13_3.sci new file mode 100755 index 000000000..c3bee369b --- /dev/null +++ b/659/CH13/EX13.3/exm13_3.sci @@ -0,0 +1,65 @@ +// Example 13.3
+//Write a program to create a linear linked list interactively
+//and print the list and total number of items in the list.
+
+funcprot(0);
+NULL=0;i=1;
+//Create the list
+function [List]=create(list1)
+ global List;
+ //Create the current node in the list
+ list1.number=input("Input a number(Type -999 to end); ")
+ if list1.number==-999 then
+ list1.next=NULL;
+ list1.add=NULL;
+ else
+ //Create the next node in the list
+ list1.add=list1.add+1;
+ list1.next=NULL;
+ List(i)=list1;
+ if(i==1) then
+
+ else
+ List(i-1).next=List(i).add
+ end
+ i=i+1;
+ create(list1); //Call create() function
+ end
+ return;
+endfunction
+//Function to print the numbers of list
+function []=print1(list1)
+ if list1(i)(1).next~=NULL then
+ printf("%d--->",list1(i)(1).number);//Print current item
+ i=i+1;
+ if list1(i)(1).next==NULL then
+ printf("%d",list1(i)(1).number);
+ end
+ print1(list1);//Move to next item
+ end
+ return;
+endfunction
+//Function to count the number of items in the list
+function []=count(list1)
+ global c;
+ if list1(i)(1).next==NULL then
+ return;
+ else
+ i=i+1;
+ c=i;
+ count(list1);
+ end
+ return;
+endfunction
+//Create the structure i.e. node
+node=struct('number',0,'add',0,'next',0);
+head=node;
+global List;
+//Calling the functions
+List=create(head);
+print1(List);
+global c;
+c=1;
+count(List);
+//Print the total number of items
+printf("\nNumber of items = %d",c);
\ No newline at end of file diff --git a/659/CH13/EX13.3/exm13_3_output.PNG b/659/CH13/EX13.3/exm13_3_output.PNG Binary files differnew file mode 100755 index 000000000..1f265235a --- /dev/null +++ b/659/CH13/EX13.3/exm13_3_output.PNG diff --git a/659/CH13/EX13.4/exm13_4.sci b/659/CH13/EX13.4/exm13_4.sci new file mode 100755 index 000000000..85044f29f --- /dev/null +++ b/659/CH13/EX13.4/exm13_4.sci @@ -0,0 +1,76 @@ +// Example 13.4
+//Write a function to insert a given item before a specified node known as
+//key node.
+
+funcprot(0);
+//Create the list
+function [List]=create(list1)
+ global List;
+ // Create the current node
+ list1.number=input("Input a number(Type -999 to end); ");
+ if list1.number==-999 then
+ list1.next=NULL;
+ list1.add=NULL;
+ else
+ list1.add=list1.add+1;
+ list1.next=NULL;
+ List(i)=list1;
+ if(i==1) then
+
+ else
+ List(i-1).next=List(i).add
+ end
+ i=i+1;
+ create(list1);// Creates the next node
+ end
+ return;
+endfunction
+//Function to insert the item before the specified key node
+function [List]=insert(list1)
+ x=input("Value of new item?");
+ printf("Value of key item?(Before which you want to insert?)");
+ key=scanf("%d");
+ while list1(i)(1).next~=NULL
+ i=i+1;
+ end
+ j=i+1;
+ //Find the key node and insert the new node
+ while(list1(i)(1).number~=key)
+ list1(i+1)(1).number=list1(i)(1).number;
+ i=i-1;
+ if(i==0) then
+ printf("Item not Found");
+ return;
+ end
+ end
+ list1(i+1)(1).number=list1(i)(1).number
+ list1(i)(1).number=x; //Inset the new node before the key node
+ list1(j)(1).add=j;
+ list1(j)(1).next=NULL;
+ list1(j-1)(1).next=list1(j)(1).add;
+ List=list1;
+endfunction
+//Function to print the numbers of list
+function []=print1(list1)
+ if list1(i)(1).next~=NULL then
+ printf("%d--->",list1(i)(1).number);//Print current item
+ i=i+1;
+ if list1(i)(1).next==NULL then
+ printf("%d",list1(i)(1).number);
+ end
+ print1(list1);//Move to next item
+ end
+ return;
+endfunction
+global List;
+NULL=0;i=1;
+//Create the structure i.e. node
+node=struct('number',0,'add',0,'next',0);
+head=node;
+//Calling the functions
+List=create(head);
+printf("\nOriginal List: ");
+print1(List);
+List=insert(List);
+printf("\nNew List: ");
+print1(List);
\ No newline at end of file diff --git a/659/CH13/EX13.4/exm13_4_output.PNG b/659/CH13/EX13.4/exm13_4_output.PNG Binary files differnew file mode 100755 index 000000000..dff486578 --- /dev/null +++ b/659/CH13/EX13.4/exm13_4_output.PNG diff --git a/659/CH13/EX13.5/exm13_5.sci b/659/CH13/EX13.5/exm13_5.sci new file mode 100755 index 000000000..c23558f6c --- /dev/null +++ b/659/CH13/EX13.5/exm13_5.sci @@ -0,0 +1,68 @@ +// Example 13.5
+//Write a program/function to delete a specified node.
+
+funcprot(0);
+//Create the list
+function [List]=create(list1)
+ global List;
+ // Create the current node
+ list1.number=input("Input a number(Type -999 to end); ")//scanf("%d");
+ if list1.number==-999 then
+ list1.next=NULL;
+ list1.add=NULL;
+ else
+ list1.add=list1.add+1;
+ list1.next=NULL;
+ List(i)=list1;
+ if(i==1) then
+
+ else
+ List(i-1).next=List(i).add
+ end
+ i=i+1;
+ create(list1);// Create the next node
+ end
+ return;
+endfunction
+//Function to print the numbers of list
+function []=print1(list1)
+ if list1(i)(1).next~=NULL then
+ printf("%d--->",list1(i)(1).number);//Print current item
+ i=i+1;
+ if list1(i)(1).next==NULL then
+ printf("%d",list1(i)(1).number);
+ end
+ print1(list1);//Move to next item
+ end
+ return;
+endfunction
+//Function to delete the specified node
+function [List]=delet(list1)
+ key=input("Value of item number to be deleted?");//Read value of key
+ //Find and delete the key node
+ while(list1(i)(1).number~=key) then
+ if list1(i)(1).next==NULL then
+ printf("Item not found in the list");
+ return;
+ end
+ i=i+1;
+ end
+ while(list1(i).next~=NULL)
+ list1(i)(1).number=list1(i+1)(1).number;
+ i=i+1;
+ end
+ list1(i-1)(1).next=NULL;
+ List=list1;
+endfunction
+global List;
+NULL=0;i=1;
+//Create the structure i.e. node
+node=struct('number',0,'add',0,'next',0);
+head=node;
+//Calling the functions
+List=create(head);
+printf("\nOriginal List: ");
+print1(List);
+List=delet(List);
+printf("\nAfter deletion List is: ");
+print1(List)
\ No newline at end of file diff --git a/659/CH13/EX13.5/exm13_5_output.PNG b/659/CH13/EX13.5/exm13_5_output.PNG Binary files differnew file mode 100755 index 000000000..4fae995f6 --- /dev/null +++ b/659/CH13/EX13.5/exm13_5_output.PNG diff --git a/659/CH13/EX2.cs/Casestudy2.sci b/659/CH13/EX2.cs/Casestudy2.sci new file mode 100755 index 000000000..995b81830 --- /dev/null +++ b/659/CH13/EX2.cs/Casestudy2.sci @@ -0,0 +1,68 @@ +// Case Study: Chapter:13 ,Page No.:438
+// 2.Building a Sorted List
+
+funcprot(0);
+//Create the list
+function [List]=create(list1)
+ global List;
+ // Create the current node
+ list1.number=input("Input a number(Type -999 to end); ");
+ if list1.number==-999 then
+ list1.next=NULL;
+ list1.add=NULL;
+ else
+ list1.add=list1.add+1;
+ list1.next=NULL;
+ List(i)=list1;
+ if(i==1) then
+
+ else
+ List(i-1).next=List(i).add
+ end
+ i=i+1;
+ create(list1);// Create the next node
+ end
+ return;
+endfunction
+function []=print1(list1)
+ if list1(i)(1).next~=NULL then
+ printf("%d--->",list1(i)(1).number);//Print current item
+ i=i+1;
+ if list1(i)(1).next==NULL then
+ printf("%d",list1(i)(1).number);
+ end
+ print1(list1);//Move to next item
+ end
+ return;
+endfunction
+//Sorting of the numbers in the list
+function [List]=insert_sort(list1)
+ global List;
+ j=1;
+ while (list1(j)(1).next~=NULL)
+ i=1;
+ while (list1(i)(1).next~=NULL)
+ if(list1(i)(1).number >list1(i+1)(1).number) then
+ temp=list1(i)(1).number;
+ list1(i)(1).number=list1(i+1)(1).number;
+ list1(i+1)(1).number=temp;
+ end
+ i=i+1;
+ end
+ j=j+1;
+ end
+ List=list1;
+endfunction
+
+global List;
+NULL=0;i=1;
+//Create the structure i.e. node
+node=struct('number',0,'add',0,'next',0);
+head=node;
+//Calling the functions
+List=create(head);
+printf("\nOriginal List: ");
+print1(List);
+List=insert_sort(List); //Sort the list
+printf("\nAfter sorting: ");
+print1(List);
\ No newline at end of file diff --git a/659/CH13/EX2.cs/Casestudy2_output.PNG b/659/CH13/EX2.cs/Casestudy2_output.PNG Binary files differnew file mode 100755 index 000000000..b54219d17 --- /dev/null +++ b/659/CH13/EX2.cs/Casestudy2_output.PNG |