Representing a matrix | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Representing a matrix

I wonder how I can represent a matrix using linked lists in a way that I can loop through the columns/rows easily What I have intended now is: I have a class Node(self, value, right, down): Where right represents the columns and down rows Then I have another class Matrix(self, numrows, numcols, defaultvalue=0) How can I represent it so that i can easily set a value a given row and column, or get a specific row with its values? Thanks!

1st Jul 2017, 10:35 PM
Rockiecoder
Rockiecoder - avatar
2 Antworten
+ 6
Why would you want to do that? Frankly inefficient way of manipulating a matrix.
1st Jul 2017, 10:58 PM
Karl T.
Karl T. - avatar
+ 1
It is, but it's at the same time a great way to practice and know more about linked lists. An easier approach would be creating a list inside a list, but it would end up using too much space as compared to linked lists
1st Jul 2017, 11:03 PM
Rockiecoder
Rockiecoder - avatar