{"id":12765,"date":"2021-09-30T16:30:42","date_gmt":"2021-09-30T11:00:42","guid":{"rendered":"https:\/\/python-programs.com\/?p=12765"},"modified":"2021-11-22T18:33:34","modified_gmt":"2021-11-22T13:03:34","slug":"python-program-to-find-a-fixed-point-in-a-given-array-or-list","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-a-fixed-point-in-a-given-array-or-list\/","title":{"rendered":"Python Program to Find a Fixed Point in a given Array or List"},"content":{"rendered":"

An array is a type of variable that can hold several values at once.<\/p>\n

One element in a fixed point array is given as if its value is the same as its index. If a value is present, the code will return it; otherwise, it will return -1. We have an array of x unique numbers sorted in ascending order in this. In the following code, we create a function that returns a fixed point integer and returns -1 if there is no fixed point integer. The fixed point index is defined as an index I such that array[i] equals i.<\/p>\n

Given a list, the task is to find a fixed point in the given list in Python if the fixed point is present in the given list then print -1.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given List = [19, 24, 25, 3, 81, 144, 600, 900, 225, 4, 9, 1, 16, 49, 23, 49, 25, 10, 25]<\/pre>\n

Output:<\/strong><\/p>\n

The Fixed point present in the given list is [ 3 ]<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given list = [7 , 8, 45, 19, 21, 23, 6 ,7, 5,]<\/pre>\n

Output:<\/strong><\/p>\n

The Fixed point present in the given list is [ 6 ]<\/pre>\n

Program to Find a Fixed Point in a given Array or List\u00a0Python<\/h2>\n

Below are the ways to find a Fixed Point in the given list in Python.<\/p>\n