answersLogoWhite

0


Best Answer

An array offers the most efficient method of implementing a matrix (an n-dimensional array). All arrays implicitly convert to pointers, so a pointer can be treated as an array even when it doesn't actually refer to one (so long as you don't access memory that doesn't actually belong to your program, of course).

If you don't want to use an array, use linked lists instead. Each node is a member of two or more lists, so each node requires at least one node pointer per list. If you require bi-directional traversal, each node requires at least two node pointers per list. For a two-dimensional, bi-directional matrix, each node requires up, down, left and right node pointers. For a three-dimensional, bi-directional matrix, each node requires forward and backward node pointers. For a generalised n-dimensional, bi-directional matrix, each node requires an array of n pairs of pointers, one pair for each dimension.

There are very few reasons to resort to linked lists to implement a matrix. For any given number of dimensions and elements, arrays will use far less memory and are much quicker to navigate than a linked list. One of the few exceptions is when you need to slice the matrix (to insert or extract rows or columns, for instance). In these cases it is generally more efficient to break or create a sequence of links than it is to move elements in order to remove or create gaps in the array, not to mention the reallocation of the entire matrix whenever an insert is required. However, this can be largely alleviated by implementing the matrix as separately allocated arrays. E.g., for a three-dimensional array of type T, use a T*** to refer to an array of type T**, where each pointer in that array refers to separately allocated arrays of type T*, where each pointer in those arrays refers to separately allocated arrays of type T. The pointer arithmetic is exactly the same as it would be if the matrix were allocate contiguously as a single block.

Another reason we might prefer a linked list implementation is when the array is sparse and largely contains no data. In this case, each node pointer refers to the nearest neighbouring node that holds data -- the non-data nodes in between can be omitted completely, thus reducing memory consumption and speeding up traversal.

Note that space and time complexities only give us a general sense of an algorithm's performance. Only a real-world performance test will tell us which algorithm is most suitable for a given task. There is no one-size-fits-all solution, hence C does not provide a built-in matrix type.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you create c program for matrix using pointer without array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Cannon matrix multiplication program?

maltiplication of matrix for algorithme


How do you Write A program in c language for checking a diagonal matrix?

Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.


How can you write a program which proves that a multiple of a matrix and its determinant is an identity matrix?

Automated proofs are a complicated subject. If you are not an expert on the subject, all you can hope for is to write a program where you can input a sample matrix (or that randomly generates one), and verifies the proposition for this particular case. If the proposition is confirmed in several cases, this makes the proposition plausible, but is by no means a formal proof.Better try to prove it without writing any program.Note: it is not even true; it is the inverse of the matrix which gives identity when is multiplied with the original matrix.


Write a c program to determine whether a matrix is singular or not?

A c program is also known as a computer program. A singular matrix has no inverse. An equation to determine this would be a/c=f. <<>> The determinant of a singular matix is zero.


What is matrix programming in C programming?

C Examples on Matrix OperationsA matrix is a rectangular array of numbers or symbols arranged in rows and columns. The following section contains a list of C programs which perform the operations of Addition, Subtraction and Multiplication on the 2 matrices. The section also deals with evaluating the transpose of a given matrix. The transpose of a matrix is the interchange of rows and columns.The section also has programs on finding the trace of 2 matrices, calculating the sum and difference of two matrices. It also has a C program which is used to perform multiplication of a matrix using recursion.C Program to Calculate the Addition or Subtraction & Trace of 2 MatricesC Program to Find the Transpose of a given MatrixC Program to Compute the Product of Two MatricesC Program to Calculate the Sum & Difference of the MatricesC Program to Perform Matrix Multiplication using Recursion

Related questions

2x2 matrix multiplication program in 8085 processor?

how to write a program for matrix multiplication in microprocesspr


Write a program to multiply 33 matrix.?

write a program to multily 3*3 matrix.


Use of double pointer?

A double pointer has two basic meanings. One is ofa pointer to a pointer, where changing the value ofdouble pointer will result in the original pointer being changed. Another is that of a two-dimentional array, such as a matrix, or a list of char* (e.g. in main when you use argv).


Cannon matrix multiplication program?

maltiplication of matrix for algorithme


What is the Matrix Pill?

The Matrix Pill is a program to find the person still "jacked in" to the Matrix world


How do you Write A program in c language for checking a diagonal matrix?

Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.


What is Oracle in movie The Matrix?

A sentient program .


How can you write a program which proves that a multiple of a matrix and its determinant is an identity matrix?

Automated proofs are a complicated subject. If you are not an expert on the subject, all you can hope for is to write a program where you can input a sample matrix (or that randomly generates one), and verifies the proposition for this particular case. If the proposition is confirmed in several cases, this makes the proposition plausible, but is by no means a formal proof.Better try to prove it without writing any program.Note: it is not even true; it is the inverse of the matrix which gives identity when is multiplied with the original matrix.


A c program to square matrix?

A C program to square matrix is a math problem. In the math problem you write down all the outer boundary values of matrix in a circle, then write down the inner value.


Program to display multiplication of two matrix?

The matrix multiplication in c language : c program is used to multiply matrices with two dimensional array. This program multiplies two matrices which will be entered by the user.


How do you Program a Toyota matrix key?

dealer only


How do you multiply two metrix without array?

A matrix IS an array so it is impossible to multiply a matrix without array. The answer to the multiplication of two matrices need not be an array. If the first matrix is a 1xn (row) matrix and the second is an nx1 (column) matrix, then their multiple is a 1x1 matrix which can be considered a scalar.