[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Let's get right to the chase, I have a college-level data

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 21
Thread images: 3

File: Pic03.jpg (13KB, 400x231px) Image search: [Google]
Pic03.jpg
13KB, 400x231px
Let's get right to the chase, I have a college-level data structures (on Java) exam on recursion, stacks, queues and iterators next week
I'm having problems with implementations using linked lists, any tips on how to learn these topics by myself in less than a week? I have the basic knowledge on how to work with linked lists and array lists, and I have no problem with recursion or iterators
>>
download more knowledge
>>
>>59357419
Where do you recommend doing so? I already downloaded my fill of RAM
>>
File: 20170311_174900.jpg (3MB, 4160x2340px) Image search: [Google]
20170311_174900.jpg
3MB, 4160x2340px
>>59357392
When I was learning this stuff, what I did is draw pictures. I drew pictures of each process to help me understand it.

Here's an example of a drawing I made for a linked list add in the middle of two nodes:
>>
File: FukkenSaved.png (2KB, 210x161px) Image search: [Google]
FukkenSaved.png
2KB, 210x161px
>>59357571
thanks man, I'll try that
Here's a small question, if I can access previous nodes on a linked list, I can just go to the previous node from a target node and delete it if need be? Asking because my professor says I had to do a while loop from the head until the the node before target, then do nodeToDelete.clear(), then set the list size and he fucked my grade up
>>
>>59357620
Well you can't go backwards on a single linked list, only a double linked list.

If you wanna clear a list, you would just set the firstNode variable, and any other variables that might be pointed to any nodes in the list, to null and then garbage collection would clear it all up.
>>
>>59357738
Sorry, forgot to mention it was a doubly linked list, since I just used the following loop for a singly linked list:
while(nodeToDelete.getNext()!=targetNode){
nodeToDelete.getNext();
}
nodeTodelete.clear();
size--;

Should this be sensible enough? Or is there something else wrong? There's no way to test the code since the test is handwritten (also sorry if the code doesn't appear correctly, I've never posted code snippets here)
>>
>>59357392
Why the fuck would they teach this shit with java? Nobody is ever going to do any of that in java. Recursion in java is terrible, stacks are ok but nobody would implement their own stack in java, and pretty much any data structure you'd use in java can be iterated without implementing a iterator yourself and without calling creating a iterator implicitly.

Why do they teach such useless stuff in college?
>>
>>59357883
Because muh "advanced programming" course is also taught in java and the only professor who is willing to give that class has such a fucking hard on for it
>>
>>59357620
That code looks like it deletes the node before the target node. Also that doesn't seem right. You're supposed to target the data, not the node itself. Someone using your list shouldn't need to know about the nodes.

Is the method supposed to remove an entry based on the position or based on the data?
>>
>>59357924
It's supposed to delete the node before the target node, and it's supposed to remove based on the position, it searches an object targetNode of type Node<E> on the list and does what I posted on the snippet.
>>
>>59358042
So the clear method reassigns all the pointers for you? Did you write it or was it given?
>>
>>59358138
It's assumed that the Node<E> subclass contains any and all methods for assigning, clearing and setting nodes to their respective places
>tfw the professor marked my code as wrong but he wrote "excellent!" under the time complexity analysis
>>
>>59358179
Wow, you have it easy. Normally you're supposed to write your own code to manually reassign the next and prev nodes.

Yes, you can just delete any node in the list you want.
However, if you're deleting the first or last node there might be some issue when setting the first and prev node member variables. Depending on the implementation, you would set the firstNode to the firstNode.next before clearing the first node, and the same but reversed for removing the last node.
>>
>>59358238
Thanks, I'm really not giving much details but the exams themselves have some good ideas on how to implement the code
In the case of this exercise, the list has both a dummy head and tail (if a doubly linked list), it's assumed that no exceptions will be triggered by the testers so basically all you have to do is write a properly indented code snippet of the method
I assume this test will include parts to make a push, pop, queue and dequeue methods, which luckily I have implemented with little issues
There's also this shit about a positional list, for which the professor has recommended we implement using both types of linked lists, and also using arrayLists
>>
>college

Just cheat dude. Buy a UV pen and write all the algorithms or functions that you know you'll need on a white sheet of paper. Bring it to class and say that it's for scratch paper.

I did this for 4 years and it never raised an eyebrow. The only time was when a professor asked why I would need scratch paper, I just told him that I need to visually draw out the algorithm, but that only happened once.
>>
>>59357392
>he doesn't understand linked lists
just drop out 2bh

they're probably the easiest data structure of all time
>>
>>59358422
That likely won't happen since the professor is actually autistic and doesn't allow anything other than a #2 wooden pencil (no mechanical pencils allowed) and an eraser with nothing wrapped on it so no way to cheat on that
Also he doesn't make eye contact with anyone at all, which makes going to his office a hilarious and shitty experience at the same time
>>59358455
I do understand them but their implementation always fucks me up during exams
>>
>>59358475
that doesn't make any sense. if you understood them, then the implementation should be a piece of cake.
>>
>>59358475
just remember the technique to get to the end and you're pretty much fine

node *current = head;
while(current != nullptr)
current = current->next;
return current;


and for finding a specific index:
node* getIndex(short index)
{
short currentIndex = 0;
node *current = head;

while(currentIndex != index)
{
current = current->next;
++currentIndex
}

return current;
}

that pretty much covers linked lists. if you understand them conceptually and have those tools under your belt, you're good to go
>>
>>59358505
I'm not good with exams, like the handwitten stuff
I aced the advanced programming class because it was an online JUnit test thing where you could code and test along the way and it made things a whole lot less stressing
I failed 3 classes in my college career due to stress alone
Thread posts: 21
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.