more topic chapters

Linked List

The python code is approved and is functioning properly...

Psuedocode


#Coded by Revise Zone | Indenting is required

TYPE NODE
  DECLARE Data:STRING
  DECLARE:Pointer:INTEGER
END TYPE
DECLARE List:ARRAY[1:10] OF NODE
//TO INITIALISE THE ARRAY
Nullptr←-1
Freeptr←0
Startptr←Nullptr
FOR i ← 0 TO 9
List[i].Pointer←i+1
List[10].Pointer←Nullptr

//To PUSH AND ADD NEW ITEMS
PROCEDURE PUSH(DATA)
//Could also be compared with -1
 IF Freeptr <> Nullptr
    THEN 
	   CurrentNode←Freeptr
	   List[CurrentNode].Data←DATA
	   Freeptr←List[Freeptr].Pointer
	   Previousptr←Nullptr
	   CheckNode←Startptr
	   WHILE CheckNode<>-1 AND List[CheckNode].Data < DATA DO
	        Previousptr←CheckNode
			CheckNode←List[CheckNode].Pointer
	   ENDWHILE	
	   IF Previousptr=Nullptr
	        THEN
			  //Incase there is only one node in the array
			  List[CurrentNode].Pointer←Startptr
			  Startptr←CurrentNode
			ELSE
               List[CurrentNode].Pointer←List[Previousptr].Pointer	
               List[Previousptr].Pointer←CurrentNode				   
END PROCEDURE


PROCEDURE POP(DATA) 
  //START AT THE TOP
  CheckNode←Startptr
  WHILE CheckNode<>-1 AND List[CheckNode].Data <> DATA
     Previousptr←CheckNode
	 CheckNode←List[CheckNode].Pointer
  END WHILE
  IF CheckNode<>Nullptr
     THEN
        IF CheckNode←Startptr
		    THEN
		    //Makes it unaccessable
              Startptr←List[Starptr].Pointer	

            ELSE
              List[Previousptr].Pointer←List[CurrentNode].Pointer
	      
        END IF	
        List[CurrentNode].Pointer←Freeptr
        Freeptr←CheckNode	
FUNCTION FIND(Search)
 Checkptr←Startptr
 WHILE Checkptr <>-1 AND List[Checkptr].Data<>Search DO
    Checkptr←List[Checkptr].Pointer
 ENDWHILE
 RETURN Checkptr 
END FUNCTION
PROCEDURE ACCESS()
 Checkptr←Startptr
 WHILE CheckPtr <>-1 AND List[Checkptr].Data<>Search DO
    OUTPUT Checkptr
    Checkptr←List[Checkptr].Pointer
 ENDWHILE


Python Algorithm

The code is in python for this algorithm

The code is free for anyone to copy and use...The copied code must have the same code and indentation as above

Try it yourself




Download Py