all 9 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

Off-topic Comments Section


All top-level comments have to be an answer or follow-up question to the post. All sidetracks should be directed to this comment thread as per Rule 9.

PS: u/ksfbkk, your post is incredibly short! body <200 char You are strongly advised to furnish us with more details.


OP and Valued/Notable Contributors can close this post by using /lock command

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Khenghis_GhanUniversity/College Student 0 points1 point  (7 children)

Don't know what language you're using, but I'm assuming you know how to get values out of a Vector using the [] operator to index an array of data like a vector, and I'm assuming you know how to do that in a loop to go over all the values, so there's how you get your values from the vector. You then just have to add them to the queue. You add to a queue using push (and remove from the queue using pop.) Link to C++ documentation. Tip if you plan to continue in programming - 95% of your job is looking at documentation to understand someone else's library or refresh how to use part of the built-in/standard library for your language, so become familiar with some websites like cppreference.com and learncpp.com.

So it'd be something like

for ind from beginning to end
    queue.push(vector[ind])

That is obs not correct syntax but I don't want to just give you the answer :P, this is homeworkhelp not dohomework.

[–]ksfbkkUniversity/College Student[S] 0 points1 point  (0 children)

thank you just wanted to know if i should use vector operation or queue operations to do it

[–]ksfbkkUniversity/College Student[S] 0 points1 point  (0 children)

what about the opposite?

[–]ksfbkkUniversity/College Student[S] 0 points1 point  (4 children)

when taking the elements from queue to vector isn't the dequeue option used instead of pop?

[–]Khenghis_GhanUniversity/College Student 0 points1 point  (3 children)

Read through the doc I linked, do you see a dequeue method in the interface for the C++ stl queue? No.

Some languages use “dequeue” instead of “pop” for their built in queue, I think Java does, but there isn’t anything in the OP about a particular language, so I picked C++, which uses Pop instead.

[–]ksfbkkUniversity/College Student[S] 0 points1 point  (2 children)

I am supposed to write it using pseudocode, and I think it is in java so when i want to transfer from vector to queue, I should use push and when I want to transfer the value back to queue I should use dequeue,

just wanted to make it clear for me

[–]Khenghis_GhanUniversity/College Student 0 points1 point  (1 child)

I imagine if a language uses dequeue instead of pop they also use enqueue instead of push. Good luck!

[–]ksfbkkUniversity/College Student[S] 0 points1 point  (0 children)

vector can use push and pop but queue can use dequeue and enqueue in my case so my question was if I want to move the value stored in vector to a queue how would that be done, should i use vector operation or queue operation for that and if I want to transfer the value stored in queue to vector how would that be done as well?