From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 1034/CH4/EX4.4/4s4.sce | 168 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100755 1034/CH4/EX4.4/4s4.sce (limited to '1034/CH4/EX4.4') diff --git a/1034/CH4/EX4.4/4s4.sce b/1034/CH4/EX4.4/4s4.sce new file mode 100755 index 000000000..cf9890d00 --- /dev/null +++ b/1034/CH4/EX4.4/4s4.sce @@ -0,0 +1,168 @@ +//Deletion from the list: +function[link2]=append(ele,link1) + link2=list(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,0,0); + if(link1(1)(1).add==0) + link1(1)(1).data=ele; + link1(1)(1).add=1; + link1(1)(1).nexadd=0; + link1(1)(1).prevadd=0; + link2(1)=link1(1)(1); + else + if(link1(1)(1).nexadd==0) + lin2=link1(1)(1); + lin2.data=ele; + lin2.add=link1(1)(1).add+1; + link1(1)(1).nexadd=lin2.add; + lin2.nexadd=0; + lin2.prevadd=link1(1)(1).add; + link2(1)=link1(1)(1); + link2(2)=lin2; + else + lin2=link1(1)(1); + i=1; + while(link1(i)(1).nexadd~=0) + i=i+1; + end + j=i; + lin2.data=ele; + lin2.add=link1(i).add+1; + lin2.nexadd=0; + link1(i).nexadd=lin2.add; + lin2.prevadd=link1(i).add; + link2(1)=link1(1)(1); + i=2; + while(link1(i).nexadd~=lin2.add) + link2(i)=(link1(i)); + i=i+1; + end + link2(i)=link1(i); + link2(i+1)=lin2; + end + end +endfunction +function[link2]=add(ele,pos,link1); + link2=list(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,,0,0); + i=1; + while(i<=pos) + if(link1(i).nexadd==0) + break; + else + i=i+1; + end + end + if(link1(i).nexadd~=0) + i=i-1; + lin2.data=ele; + lin2.add=i; + j=i; + while(link1(j).nexadd~=0) + link1(j).prevadd=link1(j).prevadd+1; + link1(j).add=link1(j).add+1; + link1(j).nexadd=link1(j).nexadd+1; + j=j+1; + end + link1(j).prevadd=link1(j).prevadd+1; + link1(j).add=link1(j).add+1; + lin2.nexadd=link1(i).add; + link1(i).prevadd=lin2.add; + lin2.prevadd=link1(i-1).add; + link1(i-1).nexadd=lin2.add; + k=1; + while(k