The Gateway to Computer Science Excellence
0 votes
21 views
Give an adjacency-list representation for a complete binary tree on $7$ vertices. Give an equivalent adjacency-matrix representation. Assume that vertices are numbered from $1\ to\ 7$ as in a binary heap.
in Algorithms by Boss (41.9k points) | 21 views

1 Answer

0 votes

Complete Binary Tree on 7 vertices

            
           ________1________
      _____2___          ___3__
     4         5        6      7

Adjacency List Representation:

Node# Connected With
1 2,3
2 1,4,5
3 1,6,7
4 2
5 2
6 3
7 3

Corresponding  adjacency matrix representation:

0 1 1 0 0 0 0

1 0 0 1 1 0 0

1 0 0 0 0 1 1

0 1 0 0 0 0 0

0 1 0 0 0 0 0

0 0 1 0 0 0 0

0 0 1 0 0 0 0

by (269 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,644 questions
56,531 answers
195,623 comments
101,351 users