[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
It says here you can't create your own linked list from
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 75
Thread images: 3
File: 1457647829631.png (57 KB, 292x219) Image search: [Google]
1457647829631.png
57 KB, 292x219
It says here you can't create your own linked list from scratch in your favorite programming language.

Care to explain?
>>
it's incorrect.
>>
>>53449438
Is this actually a thing? Nobody can be this stupid right?
>>
>>53449438
why would I when he language already has it as a built in feature and yes I CAN make one in C or other languages that don't have them.
>>
I don't know how to program anything at all, hell i don't even know how to do the "hello world" thing.

I'm only interested in HARDWARE as a hobby, and i'm currently studying a career completely different than anything related to computers.

Does that answer your question?
>>
I wish I got questions this easy when I was interviewing.

Instead I get shit like

>you have 15 min to implement a breakout clone no you can't use google good luck
>>
>>53449538
Excellent, you're hired!
>>
>>53449569
That's easy though.
>>
>>53449569
kek thats easy mate, I once had a job inverview where I need to code an AES encrypted chat in a nuclear submarine simulator while people threw old fish at me.
>>
>>53449438
class List {
List next;
Data data;
}
>>
>>53449438
Because it's not ruby-ish, and the features you'd need of a list are typically found in the Array class.
>>
I’d never use such a shitty language. Even Caml can do it:
type linked = N | L of int;;
>>
>>53449767
A likely story.
>>
>>53449788
Thanks for coming! We'll give you a call.
>>
>>53449438
I sorry I never could figure out how to do that.

I just manually fiddle with the electric impulse to overload the circuit into a plasma that re-condenses into a new circuit structure that runs my code as a single statement.

I find that much easier to do, especially if I have a refrigerator magnet to help manipulate the plasma.

If that is a core requirement for the job then maybe I should look at another company.
>>
>>53449438
I don't know data structures. I'm not a CS major.
I never claimed to be one.

If you want practical programming, I can do it.
If you want someone to optimize algorithms, data access times etc, then you probably need to hire someone else.
>>
>>53449933
Still waiting for that call.
>>
>>53450659
1/10 noone can actually be that retarded
>>
I'm a woman
>>
File: Master_of_his_craft.png (85 KB, 361x333) Image search: [Google]
Master_of_his_craft.png
85 KB, 361x333
>>53450659
>>
>>53449933
pls respond.
>>
>>53450803
Yeah I just googled "linked list" and it took 3 seconds to learn the basic concept.
However I'm still not an expert on data structures, which is what the question was about.

Also knowledge != intelligence you stupid highschooler.

>>53450948
what's so funny? I am literally not a CS major, I'm a geotechnical engineer.
I cannot come up with the optimal implementation of something like a novel and complex search algorithm because I'm not aware of all types of data structures, their search times etc. But I can build a working implementation. That's what I said.
>>
>>53451021
a linked ist is probably the most basical datastructure existing. you can't program anything practical without _at least_ using linked lists..
>>
>>53449438
I don't know how to not do it in python
>inb4 python
Math major
>>
>>53449438
My favorite language is Haskell; and as a purely functional programming language it doesn't support general purpose data types that you can construct lists out of.
>>
>>53451268
wtf are you smoking ?
>>
>>53449438
No it doesn't. I didn't put that on my resume.
>>
>>53451268
If Haskell is your favorite language then you should probably learn to program in it.
>>
Linked lists are pretty much the worst data structure in existence. I can write one, but refuse to do so out of principle. I will write a self resizing array list instead.
>>
>>53451903
how the fuck would you do that without linked lists ?
>>
>>53451182
I could make a game engine without linked lists.
>>
>>53449438
Node class with data and link variable
>>
>>53451923
by just using non-resizeable arrays ? sounds very memory efficient
>>
>>53449438
struct llist {
struct lnode *head;
struct lnode *tail;
};

struct lnode {
int data;
struct lnode *next;
struct lnode *prev;
}
>>
>>53451941
Your point is stupid. Nothing wrong with no memory allocations during gameplay.

No I wouldn't do that.
>>
>>53452015
>Nothing wrong with no memory allocations during gameplay.

What happens when there's more bullets on screen than the bullet_pool has memory for?
>>
>>53451903
self...resizing...array? as in, make a new array with a different size and copy everything from the first array into your new sized array? cuz there's no other way to do that... cept linked lists
>>
>>53452044
You resize you fucking turd.
>>
>>53452056
How the fuck do you resize something without memory allocation?
>>
>>53452076
How the fuck do you make a new node without memory allocation?
>>
>>53452086
that's the question: you cant !
>>
>>53449838
there's no such thing as 'ruby-ish'. it's literally the most important feature separating ruby from python: doing away with the one-way-to-do-it, it's-the-most-pythonic-solution kind of crap.
>>
>>53452086
You don't. Which is the point.

You really are fucking yourself if you refuse to use any kind of memory allocation at runtime.
>>
>>53452053
so vectors vs lists?
>>
>>53452044
You don't allow that many, or there aren't as many in a realistic condition.

>>53452076
his point still stands. You don't need to know the implementation details of allocating new memory.
Not everyone has to deal with low level shit.
>>
#include <stdio.h>
#include <stdlib.h>
#include "doublelinkedlist.h"

int main(int argc, char** argv) {
struct doublelinkedlist* colors;
size_t n;

colors = doublelinkedlist_new();
doublelinkedlist_add(colors, "green");
doublelinkedlist_add(colors, "blue");
doublelinkedlist_add(colors, "orange");
doublelinkedlist_add(colors, "yellow");

for(n = 0; n < doublelinkedlist_size(colors); n++) {
printf("element %d = %s\n", n, doublelinkedlist_get(colors, n));
}
printf("size = %d\n", doublelinkedlist_size(colors));

doublelinkedlist_free(colors);

return EXIT_SUCCESS;
}


1/3
>>
#ifndef DOUBLELINKEDLIST_HEADER
#define DOUBLELINKEDLIST_HEADER

struct doublelinkedlist {
struct doublelinkedelement* first;
size_t size;
};

struct doublelinkedelement {
void* value;
struct doublelinkedelement* next;
struct doublelinkedelement* previous;
};

struct doublelinkedlist* doublelinkedlist_new();
void doublelinkedlist_add(struct doublelinkedlist* list, void* value);
void* doublelinkedlist_get(struct doublelinkedlist* list, size_t position);
size_t doublelinkedlist_size(struct doublelinkedlist* list);
void doublelinkedlist_free(struct doublelinkedlist* list);

#endif


2/3
>>
#include <stdlib.h>
#include "doublelinkedlist.h"

struct doublelinkedlist* doublelinkedlist_new() {
struct doublelinkedlist* list;

list = malloc(sizeof(struct doublelinkedlist));
list->first = NULL;
list->size = 0;

return list;
}

void doublelinkedlist_add(struct doublelinkedlist* list, void* value) {
struct doublelinkedelement* element;
struct doublelinkedelement* last;

element = malloc(sizeof(struct doublelinkedelement));
element->value = value;
element->next = NULL;
element->previous = NULL;

if(list->first == NULL) {
list->first = element;
} else {
last = list->first;
while(last->next != NULL) {
last = last->next;
}
last->next = element;
element->previous = last->next;
}

list->size++;
}

void* doublelinkedlist_get(struct doublelinkedlist* list, size_t position) {
struct doublelinkedelement* element;
size_t n;

element = list->first;
for(n = 0; n < position; n++) {
element = element->next;
}

return element->value;
}

size_t doublelinkedlist_size(struct doublelinkedlist* list) {
return list->size;
}

void doublelinkedlist_free(struct doublelinkedlist* list) {
struct doublelinkedelement* element;
struct doublelinkedelement* next;

element = list->first;
while(element != NULL) {
next = element->next;
free(element);
element = next;
}

free(list);
}


3/3
>>
>>53449438
Lies and slander
>>
>>53452251
>You don't need to know the implementation details of allocating new memory.
>Not everyone has to deal with low level shit.
fucking codemonkeys. thats the reason why they only produce shit.
>>
>>53449438
Okay.
data List a = Cons a (List a) | Nil deriving (Eq, Ord, Read, Show)
>>
>>53449569
In what language?
>>
>>53452426
>O(n) insertions
m8...
>>
>>53453468
You didn't say it had to be fast.
>>
>>53451957
do you have to implement insert and remove functions?
>>
I'd talk you out of using linked lists if you gave me some context for when you'd implement one ;)
>>
File: 1298527151028.jpg (25 KB, 627x627) Image search: [Google]
1298527151028.jpg
25 KB, 627x627
>>53451957
>not calling it *prev and *next
>>
>>53454386
look again retard
>>
>>53454422
touche
>>
>>53449767
So you also got to the second round of interviews at Palantir.
>>
>>53449569
>breakout clone
the fuck even is this?
>>
>>53453468
Insertion to linked list is O(n) if you take into account finding the correct place for the node.
>>
>>53454505
its some old game that you could play on like a graphing calculator and a blackberry
>>
>>53454422
I think he meant that how you declare the pointers in the struct is a "wrong" way of doing it. Consider a basic reduce function for example, the previous value is introduced first (in most cases).
>>
>>53452614
What have you produced?
>>
>>53454552
see
>>53454444

also, wicked quads
>>
I'm not a programmer sir, I'm an electromechanical engineer, if you want me to program as well you'll need to pay me more
>>
>>53452935
I think you mean
deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Data, Typeable, Generic)
>>
>>53449438
no it fucking doesn't
why the hell would I write that down
>>
>>53455361
Yes and...
{-# LANGUAGE DeriveDataTypeable,
DeriveFunctor,
DeriveFoldable,
DeriveGeneric,
DeriveTraversable #-}
>>
>>53449438
Linked lists are the most basic data structure in Lisp. Implementing a linked list with linked lists is kind of a retarded idea.
>>
>>53449438
>putting what you can't do on your resume.

How would you even get an interview?
>>
>>53449438
Brainfuck programmers have evolved beyond such quaint constructions.
>>
linked lists are garbage but if you can't implement one you're worse than poo in loo tier and belong in the garbage
>>
yes that was right below where I put down I was a gay hispanic trangender woman
<a href"listFromScratch.html">here's your list</a>

wow thanks for the job offer omg
Thread replies: 75
Thread images: 3

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.