You are on page 1of 4

Create a class for node as template:

1. create class node:

2. initialize data part a.

3. initialize pointer node next .

4. initialize pointer node prev .

5. declare constructor node(data1):

6. a←data1.

7. end constructor.

8.end of class.

9.Create class doubleendqueue1

10.Create new node top,front,temp

11.declare constructer doubleendqueue1()

12.top←null

13.front←null

14.end constructer

15.declare mechod addlast(h)

16.temp←new node(h)

17.if top=null

18.top←temp

19.front←temp

20.else

21.top.next←temp

22.temp.prev←top

23.top←temp

24.end if
25.end addlast

26.declare method addfirst(h)

27.temp←new bode(h)

28.if(front=null)

29.top←temp

30.front←temp

31.else

32.temp.next←front

33.front.prev←temp

34.front←temp

35.end if

36.end addfirst

37.create method deletefirst()

38.try

39.create temporary node fr←front

40.front.next.prev←null

41.front←front.next

42.fr←null

43.end try

44.catch(NullPointerException c)

45.print is empty

46.front←null

47.end catch

48.end deletefirst
49.declare method deletelast()

50.try

51.declare new node temporary ls←top

52.top.prev.next←nul

53.top←top.prev

54.ls←null

55.end try

56.catch(NullPointerException c)////check the list be null

57.front←null

58.print is empty

59.front←null

60.end catch

61.end deletefirst

62.declare method check_front()//for checking front have or not

63.if don’t have

64.print is empty the list

65.else

66.print front //as queue

67.end if

68.end check_front

62.declare method check_front()//for checking top have or not

63.if don’t have

64.print is empty the list

65.else
66.print top //as stack

67.end if

68.end check_top

Finish the project

You might also like