Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Course Queries Syllabus Queries 2 years ago
Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I am new to teaching the particular syllabus I have been asked to teach and I am confused by the approach given for several of the algorithms. For example the stack implementation based on the course materials given below seems very convoluted. I'm curious to hear if others would share my concerns if they had to teach about stacks in this way, or if they can offer any insight into the advantages of this approach.
The concerns I have which I'm curious to hear your opinion about are:
Using the call by reference approach makes the push and pop calls very unwieldy
push
pop
It looks like new items are added to the end of the list, making the algorithm O(n) rather than O(1)
The algorithm is hard to follow (IMO)
It is possible to implement a stack in a much simpler fashion, which would allow student to focus more on conceptual understanding of the behavior and use of stacks, and to see the link between the concept and the implementation more clearly.
# NullPointer should be set to -1 if using array element with index 0 NULLPOINTER = -1 #Declare record type to store data and pointer class Node: def __init__(self): self.Data = "" self.Pointer = NULLPOINTER def InitialiseStack(): Stack = [Node() for i in range(8)] TopOfStack = NULLPOINTER # set start pointer FreeListPtr = 0 # set starting position of free ist for Index in range(7): Stack[Index].Pointer = Index + 1 Stack[7].Pointer = NULLPOINTER # last node of free list return (Stack, TopOfStack, FreeListPtr) def Push(Stack, TopOfStack, FreeListPtr, NewItem): if FreeListPtr != NULLPOINTER: # there is space in the array # take node from free list and store data item NewNodePtr = FreeListPtr Stack[NewNodePtr].Data = NewItem FreeListPtr = Stack[FreeListPtr].Pointer # insert new node at top of stack Stack[NewNodePtr].Pointer = TopOfStack TopOfStack = NewNodePtr else: print("no space for more data") return (Stack, TopOfStack, FreeListPtr) def Pop(Stack, TopOfStack, FreeListPtr): if TopOfStack == NULLPOINTER: print("no data on stack") Value = "" else: Value = Stack[TopOfStack].Data ThisNodePtr = TopOfStack TopOfStack = Stack[TopOfStack].Pointer Stack[ThisNodePtr].Pointer = FreeListPtr FreeListPtr = ThisNodePtr return (Stack, TopOfStack, FreeListPtr, Value) def OutputAllNodes(Stack, TopOfStack) : CurrentNodePtr = TopOfStack # start at beginning of list if TopOfStack == REPLY 0 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Course Queries 4 Answers
Course Queries 5 Answers
Course Queries 1 Answers
Course Queries 3 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.